Home  >  Article  >  Web Front-end  >  Summary of methods for obtaining id values ​​in jquery_jquery

Summary of methods for obtaining id values ​​in jquery_jquery

WBOY
WBOYOriginal
2016-05-16 17:22:031151browse

Copy code The code is as follows:



eq(0) takes the first jq element. . .

eq(index)
matches an element with a given index value

Matches a single element by its index.
Return value
Element

Parameter
index (Number): counting from 0

Example
Find the second row

HTML code:

Copy code The code is as follows:


< ;td>Header 1


Value 1
Value 2< /td>

jQuery code:

Copy code The code is as follows:

$("tr:eq(1)")

Result:

Copy code The code is as follows:

[ Value 1< /td> ]

Get values ​​of different ids

Copy code The code is as follows:



aaa,


bbb,


ccc,


ddd,


eee,


This will get all the ids you want:
0_1
0_2
0_3
0_4
0_5

Text box, text area:

Copy code The code is as follows:

$("#txt").attr("value ",'');//Clear content
$("#txt").attr("value",'11');//Fill content

Multiple selection box checkbox:

Copy code The code is as follows:

$("#chk1").attr("checked ",'');//Unchecked
$("#chk2").attr("checked",true);//Checked
if($("#chk1").attr( 'checked')==undefined) //Determine whether it has been checked
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn