我建了一个这样的表:
<table id="testTable">
<tr>
<td dir="ltr"><a href="#">array()</a></td>
<td>انشاء مصفوفة</td>
<td>530</td>
<td><a class="example1" href="#">12.5</a></td>
<td>12.5</td>
</tr>
<thead>
<tr>
<th colspan="5" rowspan="3" class="slide1" >
<pre class="prettyprint lang-php ">
$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse");
echo $a["b"];
//الناتج
Cat
//مثال اخر
$a=array("Dog","Cat","Horse");
print_r($a);
//الناتج
Array ( [0] => Dog [1] => Cat [2] => Horse )
</pre>
</th>
</tr>
</thead>
<tr>
<td dir="ltr"><a href="">array_push()</a></td>
<td>اضافة عنصر او أكثر لنهاية المصفوفة</td>
<td>530</td>
<td class="example2">12.5</td></td>
<td>12.5</td>
</tr>
<thead>
<tr>
<th colspan="5" rowspan="3" class="slide1" >
<pre class="prettyprint lang-php ">
$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse");
echo $a["b"];
//الناتج
Cat
//مثال اخر
$a=array("Dog","Cat","Horse");
print_r($a);
//الناتج
Array ( [0] => Dog [1] => Cat [2] => Horse )
</pre>
</th>
</tr>
</thead>
<tr>
<td dir="ltr"><a href="">array_rand()</a></td>
<td>استخراج مفتاح عشوائى من المصفوفة</td>
<td>530</td>
<td class="example3">12.5</td></td>
<td>12.5</td>
</tr>
<thead>
<tr>
<th colspan="5" rowspan="3" class="slide1" >
<pre class="prettyprint lang-php ">
$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse");
echo $a["b"];
//الناتج
Cat
//مثال اخر
$a=array("Dog","Cat","Horse");
print_r($a);
//الناتج
Array ( [0] => Dog [1] => Cat [2] => Horse )
</pre>
</th>
</tr>
</thead>
........and multiple like that.....
</table>
我想通过js创建一个for循环来slideToggle与我点击<thead>
的相同<td>
,我尝试了这样的事情:
$(document).ready(function(){
for (var i=1;i<=120;i++){
$(".example" + i).click(function(){
$(".slide" + i).slideToggle(500);
})
}
});
但什么也没发生。
如何通过每一个迭代这个效果,通过它的同一个 td 来滑动切换我点击的特定主题?