jquery学习(一)

jQuery
选择器简介
•兼容CSS3选择器标准
•对选择器语法有更多扩充
•返回0、1或多个jQuery元素的集合
•集合内元素顺序和在页面上顺序一致
 
位置筛选器
:first
:last
:even
:odd
:eq(n)
:gt(n)
:lt(n)
 
子元素筛选器
:first-child
:last-child
:first-of-type
:last-of-type
:nth-child()
:nth-last-child()
:nth-of-type()
:nth-last-of-type()
:only-child
:only-of-type
 
表单筛选器
:checked
:disabled
:enabled
:focus
:button
:checkbox
:file
:image
:input
:password
:radio
:reset
:selected
:submit
:text
 
内容筛选器
:empty
:contains(text)
:has(selector)
:parent
 
其他筛选器
:lang(language)
:not(selector)
:root
:target
:hidden
:visible
:header
:animated
 

<body>
<div class='box1' id="box3">box1</div>
<div class="box2">box2</div>
<input type="text" name="username">
<script src="vendor/jquery-1.12.4.js"></script>
<script>

返回的是类数组的集合对象,类数组是具有长度的属性
$(function(){

$('box1').addclass('highlight')
var element1 = $('box1');
var element2 = $('.box1,.box2');
var element3 = $('[name="username"]');
var element4 = $('div');
var element5 = $(document.getElementById('box3'));
console.log(element1);
console.log(element2);
console.log(element3);
console.log(element4);
console.log(element5);
})
</script>

posted @ 2018-03-05 13:59  宁静花园  阅读(83)  评论(0编辑  收藏  举报