码迷,mamicode.com
首页 > Web开发 > 详细

详解Jquery选择器

时间:2017-02-16 15:52:53      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:style   move   option   bsp   html   last   end   span   htm   

1、常见的选择器

id,类,标签选择器。

$("#a1")

$("myclass")

$("div")

2、组合选择器

$("#a1,#a3,#a4,p,.myclass")

3、继承选择器

$("#d1 .myclass")

找到的对应的html元素为

<div  id=‘#d1‘><a class="myclass">链接</a></div>

 

4、按照正则表达式进行选取

$(":checkbox[id^=‘ssss‘][id$=‘xxxx‘]").each(function(){
    $(this).attr("checked", checked);
  });
  // 以ssss开头或者以xxxx结束
  $(":checkbox[id^=‘ssss‘],[id$=‘xxxx‘]").each(function(){
    $(this).attr("checked", checked);
  });

 

5、选取表单元素

radio

$(‘input:radio:checked‘).val();
$("input[type=‘radio‘]:checked").val();
$("input[name=‘rd‘]:checked").val();

 

 

select 

$(‘select#sel option:selected‘).val(); 
$(‘select#sel‘).find(‘option:selected‘).val();

 

 

 6、table操作

$(renderTo).find(‘tr:has("th"):last‘).nextAll().remove();

 

详解Jquery选择器

标签:style   move   option   bsp   html   last   end   span   htm   

原文地址:http://www.cnblogs.com/sexintercourse/p/6405938.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!