Answer the question
In order to leave comments, you need to log in
How to work with a table using Jquery?
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<style type="text/css">
table .c { color: red; }
.a .c { color: green; }
</style>
</head>
<body>
<table id="t">
<tbody>
<tr>
<td class="c">Текст</td>
</tr>
</tbody>
</table>
</body>
</html>
$("#t").find("td").eq(1).text()
Answer the question
In order to leave comments, you need to log in
Is jQuery itself connected exactly? What happens if you change the table id to another one? eq(1) is incorrect because all elements are counted from zero. Therefore, in this situation, .eq(0) will be correct.
always, when generating a table, I assign classes to cells, at least those that need to be worked with later on the client side. and the code is easier to get and you don’t need to perform terribly heavy .find()
if it’s .find() then within the framework <tr>
and not the entire table
.eq(1) is the second element, and you only have one. numbering starts from zero.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question