jQuery-wybrać drugi wiersz w tabeli?
Jak wycelować drugi <tr>
w tabeli używając jQuery? Czy używam .closest
Czy nth-child
?
// something like this..
var MyLocation = $('.myclass').closest('tr').after('tr'); // fixed
<table class ='myclass'>
<tr>
<td></td>
</tr>
<!-- put some thing here -->
<tr>
</tr>
23
3 answers
$('.myclass tr').eq(1)
To złapie drugą. 52
Author: Seth,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-11-13 23:46:33
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-11-13 23:46:33
Użyj selektora NTH-child. Zobacz http://api.jquery.com/nth-child-selector/
$('.myclass tr:nth-child(2)')
31
Author: Rob Cowie,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-11-13 23:47:22
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-11-13 23:47:22
Użyj selektora :first
w połączeniu z insertAfter()
Funkcja:
$("TheElementToInsert").insertAfter(".myClass tr:first");
6
Author: James Hill,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-11-13 23:47:46
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-11-13 23:47:46