我想使用jQuery打开和关闭一个div。
但是由于我使用的代码是动态的,并且将在彼此下面重复,因此我需要使用动态id。
HTML:
我尝试使用这个jQuery,但我猜测php代码行没有起作用:
我需要如何正确地编辑这个?
HTML:
<div class="categoryratings-review-<?php echo $this->htmlEscape($_review->getId())?>" style="display: none;">
<p>Text</p>
</div>
<span class="showcategoryratings" id="review-<?php echo $this->htmlEscape($_review->getId())?>">
<span class="showcategoryratings-text">Per category</span>
</span>
我尝试使用这个jQuery,但我猜测php代码行没有起作用:
$(document).ready(function() {
$('#review-<?php echo $this->htmlEscape($_review->getId())?>').click(function() {
$('.categoryratings-review-<?php echo $this->htmlEscape($_review->getId())?>').slideToggle("fast");
$(this).toggleClass('active');
});
});
我需要如何正确地编辑这个?