jQuery 知识积累

1.select下拉框设置选中项 
//设置下拉框第一项为选中项
$("#selectId option:first").prop("selected", 'selected');
$("#selectId").find("option:first").attr("selected", 'selected'); 
$("#selectId option").eq(0).attr("selected", true);

2.:not()方法
$("selector1:not(selector2)")
$(‘li:not(:first-child)’);//匹配除了在他父元素中是第一个子元素的LI
$(‘li:not(:only-child)’)//匹配所有的li,除了只有一个子元素的
$("li :not(:first)").hide();//隐藏除了第一个LI外的所有LI

 

  

posted @ 2014-08-23 00:15  金桂花季  阅读(100)  评论(0编辑  收藏  举报