复制代码 代码如下:
$(select).change(function(){
var n = $(this).children().length;
var obj;
var i = 1;
$(this).children().each(function(){
if(i == n)
{
alert($(this).text());
}
i++;
});
});
综合以上二法,本人轻易得出了自己想要的效果,如下:
复制代码 代码如下:
function selectall()
{
$(select).children().each(function(){$(this).attr(selected,selected)})
}
分别用到了 children()和$(this).attr(selected,selected)
一个js用法
复制代码 代码如下:
(003) 娑