【www.bbyears.com--js教程】
代码如下$("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用法
<script type="text/javascript">
</script>