I'm trying to get a table using jquery for some reason I cant get the specific row
I can use some help
jquery
$('table').on('click','tr:gt(0)',function(e){
row=$(this).closest("tr");
$('tr').css('background-color', '');
row.css('background-color', 'yellow');
});
HTML
<table id="receivedFeeds" border="1">
<tr>
<th>Feed Address</th>
<th>Feed name</th>
<th>Received from</th>
</tr>
</table>
PHP
function addSendedFeedToUser(){// create a table of links and the user who send them
connectToDB();
$username=mysql_real_escape_string($_SESSION['username']);
$sql=mysql_query("SELECT * FROM send_feed WHERE user_receive='$username'") or die(mysql_error());
while($row=mysql_fetch_array($sql)){
echo '<tr> <td>'.$row['feed_url'].'</td><td>'.$row['feed_name'].'</td> <td>'.$row['user_send'].'</td></tr>';
}
}
$(this)
is enough don't use .closest()
over that, since the selector itself is a row.
$('table').on('click','tr:gt(0)',function(e){
row = $(this);
$('tr').css('background-color', 'none');
row.css('background-color', 'yellow');
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments