首页 > Web开发 > 详细

详解Jquery选择器

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

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选择器

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!