Selector Th Jquery
Solution 1:
table.row
will look specifically at the table
element and then of those elements, look for a class name of .row
. I believe for your case, you want to look for nested .row
classes in the table
element so you should change it to $('table th')
. I'm not sure what attribute scope
is but if you want to use .row
, you can define a <th class="row">
instead and then use $('table.row')
If you really want to use the attribute scope
, you can also specify that in jQuery by doing ${'th[scope="row"]')
Solution 2:
You might want to have a look at the jQuery selectors.
Elements with attributes having a specific value can be selected via [attributName="desiredValue"]
.
In your case: $('th[scope="row"]')
Solution 3:
To access <th scope="row">
:
var thScopeRow = $('th[scope="row"]');
Solution 4:
scope
is an attribute of <th>
, not class, so the correct syntax would be $('th[scope="row"]')
. In the snippet i selected this specific th
using this method and changed the color of text just for example:
$('th[scope="row"]').css("color", "red");
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><table><thead><tr><th>ID</th><th>Edit</th></tr></thead><tbody><tr><thscope="row">123</th><th><ahref=""data-toggle="modal"data-target="#formModal"><spanclass="oi"data-glyph="pencil"></span></a></th></tr></tbody></table>
UPDATE
"I inserted a class="update" in th: $('th[class="update"]')"
If you are using <th class="row">123</th>
and it's only one element on the page with such class, you can get it via $('.row')[0]
. ([0]
is needed because $('.row')
will find ALL elements on the page with such class. So think about it as an array). If you have for example 2 elements on the page with such class and want to get the second, so use $('.row')[1]
and so on.
Post a Comment for "Selector Th Jquery"