use*_*906 2 javascript jquery jquery-selectors
我想在前24个孩子上添加一个悬停,在另一个元素的24个单独元素上添加填充.
像这样:
$('tr td:nth-child(1)').mouseover(function(){
$('rect:nth-of-type(1)').css("fill", "black" );
});
$('tr td:nth-child(2)').mouseover(function(){
$('rect:nth-of-type(2)').css("fill", "black" );
});
$('tr td:nth-child(3)').mouseover(function(){
$('rect:nth-of-type(3)').css("fill", "black" );
});
Run Code Online (Sandbox Code Playgroud)
但我不想重复自己24次.什么是处理这个的最好方法?
看看lt选择器:
$('tr td:lt(24)')
Run Code Online (Sandbox Code Playgroud)
http://api.jquery.com/lt-selector/
| 归档时间: |
|
| 查看次数: |
89 次 |
| 最近记录: |