Reputation: 1816
I have this weird requirement. I have a table and inside that table I have a form. I am handling that form with the help of Jquery. Is there any way that I can get the data of the <td></td>
without having any id or class for that <td>
.
My requirement is weird. I got this code from somewhere and now I need to manage this code. If this thing dont work, I will have to manually change the code line by line and there are hundreds of such forms.
<table>
<tr>
<td>The data that i need </td>
</tr>
<tr>
<td> <form> My form </form> </td>
</tr>
</table>
Upvotes: 0
Views: 1895
Reputation: 4709
Try this:
html= $('table td:first').html();
And you can use it like this:
alert(html);
Fiddle: http://jsfiddle.net/bYccS/
Upvotes: 1
Reputation: 877
try this
jQuery.each('td', function() {
var text = $(this).html();
});
Upvotes: 0
Reputation: 3170
$($('table > tr > td')[0])
using this you will have the first td on the first tr
Upvotes: 0