Javascript²Ù×÷SelectºÍOption
×¢Òâ:OptionÖеÄOÊÇÒª´óдµÄ£¬²»È»Óï·¨±¨´í
1.¶¯Ì¬´´½¨select
function createSelect(){
var mySelect = document.createElement("select");
mySelect.id = "mySelect";
document.body.appendChild(mySelect);
}
2.Ìí¼ÓÑ¡Ïîoption
function addOption(){
//¸ù¾Ýid²éÕÒ¶ÔÏó£¬
var obj=document.getElementById('mySelect');
//Ìí¼ÓÒ»¸öÑ¡Ïî
obj.add(new Option("Îı¾","Öµ")); //Õâ¸öÖ»ÄÜÔÚIEÖÐÓÐЧ
obj.options.add(new Option("text","value")); //Õâ¸ö¼æÈÝIEÓëfirefox
}
3.ɾ³ýËùÓÐÑ¡Ïîoption
function removeAll(){
var obj=document.getElementById('mySelect');
obj.options.length=0;
}
4.ɾ³ýÒ»¸öÑ¡Ïîoption
function removeOne(){
var obj=document.getElementById('mySelect');
//index,Ҫɾ³ýÑ¡ÏîµÄÐòºÅ£¬ÕâÀïÈ¡µ±Ç°Ñ¡ÖÐÑ¡ÏîµÄÐòºÅ
var index=obj.selectedIndex;
obj.options.remove(index);
}
5.»ñµÃÑ¡ÏîoptionµÄÖµ
var obj=document.getElementById('mySelect');
var index=obj.selectedIndex; //ÐòºÅ£¬È¡µ±Ç°Ñ¡ÖÐÑ¡ÏîµÄÐòºÅ
var val = obj.options[index].value;
6.»
Ïà¹ØÎĵµ£º
¡¡½éÉÜÔõÑù½â¾öJavaScriptÒ³ÃæË¢ÐÂÓ뵯³ö´°¿ÚµÄÎÊÌâ¡£
¡¡¡¡1.ÎÞÌáʾˢÐÂÍøÒ³
¡¡¡¡´ó¼ÒÓÐûÓз¢ÏÖ£¬ÓÐЩÍøÒ³£¬Ë¢ÐµÄʱºò£¬»áµ¯³öÒ»¸öÌáʾ´°¿Ú£¬µã“È·¶¨”²Å»áˢС£
¡¡¡¡¶øÓеÄÒ³Ãæ²»»áÌáʾ£¬²»µ¯³öÌáʾ´°¿Ú£¬Ö±½Ó¾ÍË¢ÐÂÁË.
¡¡¡¡Èç¹ûÒ³ÃæûÓÐform£¬Ôò²»»áµ¯³öÌáʾ´°¿Ú¡£Èç¹ûÒ³ÃæÓÐform±íµ¥£¬
¡¡¡¡a)< fo ......
ÒªÏëд³ö¿çä¯ÀÀÆ÷µÄjavascript£¬¾Í±ØÐ붮µÃÐá̽¼¼Êõ¡£ÕâÊÇä¯ÀÀÆ÷´óÕ½ÒÅÁôϵĴóµØÀ×£¬ÊÂÒÑÈç´Ë£¬Ö»ºÃÈÏÃü£¬¹Ô¹Ôд·ÖÖ§½á¹¹°É£¬º¯Êý¾ÍÊÇÕâÑù²»Öª²»¾õÖб䳤µÄ¡£
ÏÈ¿´µ¥Ò»ä¯ÀÀÆ÷µÄÅжϣ¬ÎÒÃÇûÓбØÐëÈ¥ÕÒnavigator.userAgentµÄÂé·³£¬ÎÒÔÚ¹úÍâµÄ²©¿ÍÍøÕ¾ÊÕ¼¯ÁËÈçÏÂhack£¬¶ÌС¾«º·£º
ie = !+"\v1" ;
ie ='\v'=='v' ; ......
1:js ×Ö·û´®³¤¶ÈÏÞÖÆ¡¢ÅжÏ×Ö·û³¤¶È ¡¢jsÏÞÖÆÊäÈë¡¢ÏÞÖƲ»ÄÜÊäÈë¡¢textarea ³¤¶ÈÏÞÖÆ
2.:jsÅжϺº×Ö¡¢ÅжÏÊÇ·ñºº×Ö ¡¢Ö»ÄÜÊäÈ뺺×Ö
3:jsÅжÏÊÇ·ñÊäÈëÓ¢ÎÄ¡¢Ö»ÄÜÊäÈëÓ¢ÎÄ
4:jsÖ»ÄÜÊäÈëÊý×Ö,ÅжÏÊý×Ö¡¢ÑéÖ¤Êý×Ö¡¢¼ì²âÊý×Ö¡¢ÅжÏÊÇ·ñΪÊý×Ö¡¢Ö»ÄÜÊäÈëÊý×Ö
5:Ö»ÄÜÊäÈëÓ¢ÎÄ×Ö·ûºÍÊý×Ö
6: js emailÑéÖ¤ ¡¢js ÅÐ¶Ï ......
srcElement ÊÇDomʼþÖеÄʼþ×î³õÖ¸Åɵ½µÄÔªËØ¡£
±ÈÈçÓÐÒ»¸ödiv£¬ÀïÃæÓÐÒ»¸ö°´Å¥¡£ÄãÏìÓ¦divµÄonclickʼþ£¬µ«Êµ¼ÊÉÏ£¬Äãµ¥»÷µÄÖ»ÊÇËüÄÚ²¿µÄ°´Å¥£¬ÄÇô£¬srcElementÖ¸ÏòµÄ£¬¾ÍÊÇÄǸö°´Å¥¡£
srcElementÖ»ÔÚIEÖÐÓÐЧ¡£
ÔÚOperaϵÁÐä¯ÀÀÆ÷ÖжÔÓ¦µÄÊôÐÔÊÇtarget
¸øÄãÒ»¸öIEÏÂʹÓõÄÀý×Ó¡£
<!DOCTYPE html PUBLIC "-//W ......
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server"> </script>
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">
<title ......