Example one:
<table>
<tr>
<th> user name </th>
<th> status </th>
<tr>
< Tr>
<td> John </td>
<td data-uid= "10000" > Normal </td>
<tr>
<tr>
<td> Dick </td>
<td data-uid= "10001" > Frozen </td>
<tr>
<tr>
<td> Wang Leper </td>
<td data-uid=10002> freeze </td>
<tr>
</table>
<script type= "Text/javascript" >
$ (document). Ready (function () {
var uid = 1001;
$ ("Td[data-uid =" + UID + "]"). html (' normal ');
</script>
Example two:
<script type= "Text/javascript" >
$ (function () {
alert (123);
var v=4;
var test=$ ("Input[type= ' Radio '][value= '" +v+ "]")//direct concatenation of strings can be
console.info (test);
var testvalue=test.attr ({"Checked": true});
Console.info (TestValue);
});
</script> <body> This are my
JSP page. <br>
<table>
<tr>
< td> sex:</td>
<td>
<input name= "Sex" type= "Radio" value= "0"/> Men 0
<input name= " Sex "type=" Radio "value=" 1 "/> Women 1 <input name=" Sex "
type=" Radio "value=" 2 "/> Women 2
<input name=" Sex " Type= "Radio" value= "3"/> Female 3
<input name= "Sex" type= "Radio" value= "4"/> Women 4
</td>
</ tr>
</table>
</body>
Example three, the problem that the selector parameter uses the variable in jquery should notice
This is the original code.
var Li_index = $ (this). index ();
var $content _index = Li_index + 2;
var $content _progress = $ ("Div.content:eq (" + $content _index +) ");
var $newavalue = $ (this). Find ("a"). attr ("name");
var $resource = $ (this). Find ("a"). html (). Replace ("Home", $newavalue);
var $afterresource = $resource. Replace ($newavalue, "");
var $afterresource = $newavalue + $afterresource. Replace ("Home", $newavalue);
Implementation is the keyword replacement, but to the third line when not executed, debugging Ah, replace Ah, no. From the morning to just have been in various groups of questions, finally ... The Lomu of our base camp saw the blood of the Great God:
You're not writing it right.
To connect a character
$ ("Div.content:nth-child ($content _index)");
To
$ ("Div.content:nth-child (" + $content _index + ")");
The point is, there's quotes outside.
There are quotes being processed as strings
Really now feel, some basic things go wrong, light on their own debugging can not find the problem. For example, the + number just now, I have not seen the book. Baidu also does not know what the keyword. I really do not know the selector with a variable to use the + number, that "sharp jquery" also does not explicitly say the selector inside with a variable to use the + number, including our w3cschool.