Using this code :
$("table > :not(thead) > tr.Selected").removeClass('Selected')
To find all table rows which have the class Selected and remove that class.
Plus, using this code :
var ReqID = $("table > :not(thead) > tr.Selected").attr('id')
Which is trying to find the ID off the row which has the class selected.
This code works perfectly until the table is reloaded using AJAX and then it all stops working and that line does not work.
Any ideas?
Thankss!
EDIT
More Code :
Here is the AJAX call :
function EditRequest()
{var ReqID = $("table > :not(thead) > tr.Selected").attr('id')
alert(ReqID);
$.post("a/outputresults2.php", {editdynamic: ReqID} , function(data){
$('#resultstable').html(data);
});
}
function Selected(x)
{
$("table > :not(thead) > tr.Selected").removeClass('Selected')
$('#'+x).toggleClass('Selected');
}
Here is the php that outputs the original and the table updated when its been AJAX'ed :
if($RequestID == $ID){
$requestrows.="
<tr id=\"$RequestID\" onClick=\"Selected($RequestID)\" class=\"Selected\" >
<td><input type=\"text\" id=\"MCode\" value=\"$ModCode\"></td>
<td><input type=\"text\" id=\"RName\" value=\"$RoomName\"></td>
..etc etc etc
</tr>";
}
}
if($RequestID != $ID){
$requestrows .=
" <tr id= \"$RequestID\" onClick=\"Selected($RequestID)\" >
<td>$ModCode</td>
<td>$RoomName</td>
... etc etc etc
</tr>";
}
}
echo($requestrows);
Also table being dynamically changed is called resultstable
Thanks