Reputation: 5201
I have a table with td's with id. I need to select those td's and reorder the columns.
$('table tr').each(function () {
var tr = $(this);
var tds = $('#Status');
var tdA = $('#Address');
alert(tds.innerHtml); //Here am getting a blank msg
tds.remove().insertAfter(tda); //This is what i need to do
});
Upvotes: 7
Views: 37069
Reputation: 548
we can use :
$('table > tr > td#Status');
$('table > tr > td#Address');
Upvotes: 0
Reputation: 5201
I found the answer:
var tds = tr.find("td[id='Status']");
//what i was looking for
Thanks for ur support and special thanks for voting my genuine question 2 points down :D, since iam not point hungry, No offense :-)
Upvotes: 14
Reputation: 4170
var selectedTd = $("#ID_OF_TD");
or to call the method like on click etc etc you can directly call the method
$("#ID_OF_TD").click(function(){
});
you need to put this code in document ready section ..
$("document").ready(function(){
$("#ID_OF_TD").click(function(){
alert('td clicked');
});
});
Upvotes: 3
Reputation: 57095
Use Id Selector
$('#tdID')
//^# followed by html id
Upvotes: 0
Reputation: 15501
Simply do $("#idHere")
.
More Info: http://api.jquery.com/category/selectors/
Upvotes: 0