javascript»ñÈ¡selectµÄֵȫ½â
»ñÈ¡ÏÔʾµÄºº×Ö
document.getElementById("bigclass").options[window.document.getElementById("bigclass").selectedIndex].text
»ñÈ¡Êý¾Ý¿âÖеÄid
window.document.getElementById("bigclass").value
»ñÈ¡select×é·ÖÅäµÄË÷Òýid
window.document.getElementById("bigclass").selectedIndex
Àý×Ó£º
<select name="bigclass" id="bigclass" onChange="javascript:updatePage2();">
<option value="" selected="selected">ajaxʵÑé</option>
<option value="4">ÎÒÊÊÒËÊйþ</option>
</select>
ʹÓÃ
document.getElementById("bigclass").options[window.document.getElementById("bigclass").selectedIndex].text
µÄ½á¹ûÊÇ£ºÎÒÊÊÒËÊйþ
ʹÓÃ
window.document.getElementById("bigclass").value
µÄ½á¹ûÊÇ£º4
ʹÓÃ
window.document.getElementById("bigclass").selectedIndex
µÄ½á¹ûÊÇ£º1
Ò»¡¢ÐÂÔöÒ»¸öoption
var sel=document.getElementById("selectµÄid");
var op=document.createElement("option");
op.value=Öµ;
op.text=ÏÔʾÎı¾;
sel.add(op);
¶þ¡¢É¾³ýÒ»¸öoption
var sel=document.getElementById("typelist");
if(sel.selectedIndex==-1)
alert("ÇëÑ¡ÖÐҪɾ³ýµÄÏî!");
for(var i=0;i<sel.options.length;i++){
if(sel.options[i].selected){
sel.options.remove(i);
break;
}
}
Èý¡¢Çå¿ÕselectµÄËùÓÐoption
var citySel=document.getElementById("selectµÄid");
citySel.options.length=0;
ËÄ¡¢»ñµÃÑ¡ÖÐÏîµÄÖµ
var citySel=document.getElementById("selectµÄid");
var selectedValue=citySel.value;
Îå¡¢»ñµÃµ±Ç°Ñ¡ÖÐÏîµÄË÷Òý
var selectedIndex=document.all.objSelect.selectedIndex;
Áù¡¢ÉèÖÃselectµÄµ±Ç°Ñ¡ÖÐÏî
·½·¨1(µ¥¸öselect)£º document.getElementById("products_type_id").selectedIndex=1;
·½·¨2(¼¶ÁªselectÈçÊ¡Êм¶Áª)£º
var province_sel=document.getElementById("province");//
Ïà¹ØÎĵµ£º
ÔÚJavaScriptÖÐûÓÐרÃŵĻúÖÆÀ´ÊµÏÖÀàµÄ¼Ì³Ð£¬µ«ÊÇ¿ÉÒÔͨ¹ý¿½±´Ò»¸öÀàµÄprototypeµ½ÁíÍâÒ»¸öÀàÀ´ÊµÏּ̳У¬Ò»ÖÖ¼òµ¥µÄʵÏÖÈçÏ£º
function class1(){
}
function class2(){
}
class2.prototype=class1.prototype;
class2.prototype.moreProperty="xxx";
class2.prototype.moreMethod1=function(){
}
var obj = ne ......
ÃüÃû¿Õ¼ä£¬Ò»¿´¾ÍÖªµÀÖ÷ҪĿµÄÊÇΪÁ˱ÜÃâ³åÍ»¡£ÏÂÃæ¾ÍÀ´ËµÒ»ÏÂÈçºÎ´òÔì×Ô¼ºµÄJavaScriptÃüÃû¿Õ¼ä¡£
´òÔìJavaScriptÃüÃû¿Õ¼äÆäʵºÜ¼òµ¥£¬Ö»ÐèÒª½«×Ô¼ºµÄº¯Êý¡¢¶ÔÏó¡¢±äÁ¿µÈ·ÅÔÚÒ»¸öαÃüÃû¿Õ¼äÖУ¬¼´ÓÃÒ»¸öÄäÃûº¯Êý°ü×°ÆðÀ´¡£
(function(){
function $(id){
&n ......
±¾ÎÄ·ÇÔ´´
Object.extend = function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
return destination;
}
Prototype ¶ÔObjectÀའ......
ͼÏñµØͼָµÄÊÇ´øÓпɵã»÷ÇøÓòµÄͼÏñ¡£
ʵÀý
¼òµ¥µÄ HTML ͼÏñÓ³Éä
±¾ÀýÑÝʾһ·ùûÓÐÌí¼Ó JavaScript µÄͼÏñÓ³Éä¡£
Ìí¼ÓÁË JavaScript µÄͼÏñÓ³Éä
±¾ÀýÑÝʾһ·ùÌí¼ÓÁË JavaScript µÄͼÏñÓ³É䣬µ±Êó±ê¸¡¶¯ÓÚij¸öÈȵãÉÏʱ£¬»áµ÷Óà JavaScript º¯ÊýÀ´ÏÔʾÈȵãËù¶ÔÓ¦µÄÐÇÇòµÄ¼ò½é¡£
JavaScript ͼÏñµØͼ
ÎÒÃÇÒѾ ......
//ÅжÏÊäÈëÄÚÈÝÊÇ·ñΪ¿Õ
function IsNull(){
var str = document.getElementById('str').value.trim();
if(str.length==0){
alert('¶Ô²»Æð£¬Îı¾¿ò²»ÄÜΪ¿Õ»òÕßΪ¿Õ¸ñ!');//Ç뽫“Îı¾¿ò”¸Ä³ÉÄãÐèÒªÑéÖ¤µÄÊôÐÔÃû³Æ!
}
}
//ÅжÏÈÕÆÚÀàÐÍÊÇ·ñÎ ......