Long heard of the name of jquery, has not studied carefully, through the reading of some of the data collected, feel jquery is really powerful. decided to start their own learning jquery trip. Here is not for you to explain jquery (know the level is limited), but to share their own learning results to everyone, learn and communicate together.
Introduction to jquery
The jquery I understand is a powerful JavaScript class library that encapsulates many of the existing methods and properties. Enables developers to develop the effects they want to achieve faster and with little code. Too much jquery here is not much to introduce, presumably a lot of people have read more detailed documents, I will not wordy.
Selectors (selector)
Using $ in jquery, you can easily get the element by the ID of the element, CSS class, or tag name.
(1) Easy to get elements
Example:
$("p") //获取所有的P元素
$("#pid") //通过 ID
$(".p") //通过css class name
(2) Of course, his function is not limited to this, but also can drill the hierarchy
Example:
$("table > tbody > tr") //获取Table的所有行
$("#t1 > tbody > tr") //获取t1 中所有行
$(".table > tbody > tr") // 获取css类名为.table的所有 行
(3) jquery provides a powerful filter to enable developers to select the appropriate elements more accurately and conveniently:
Example:
$(“p:first”) //first
$(“p:last”) //last
$(“table > tbody > tr:even”) //even rows
$(“table > tbody > tr:odd”) //odd rows
$(“p:eq(1)”) //索引为1
$(“p:gt(2)”) //2以上的元素
$("p:lt(10)”) // 0-9
$(“p:empty”) //没有子孩子的p
$(“p:parent”) //为父的p