我需要在选中复选框时重写2 <p>
标记中的html。注意:<div class="summary">
容器根据数据库的输出重复多次。如何使用.html()稍后在文档中更改内容
* HTML *
<div class="summary">
<div>Data 1</div>
<div>Data 2</div>
<div class="col_5"><input type="checkbox" /></div>
</div>
<div class="details">
<p>label:</p><p>info</p>
<p>label 2:</p><p>more info</p>
<p class="jQuery1">another label to be changed:</p><p class="jQuery2">final info to be changed</p>
</div>
* JavaScript的(一切正常,除注释1 & 2)*
$(document).ready(function(){
$('input:checkbox').change(function(event) {
$(this).closest('div.col_5').html('Yes');
$('div.details').next('p.jQuery1').html('Changed 1'); // c1 -- this does not work
$('div.details').next('p.jQuery2').html('Changed 2'); // c2 -- this does not work
});
$('.summary').click(function(e){
if ($("input:checked").length == 0) {
$(this).next('.details').slideToggle('slow');
}
});
});
在我的脚本中不适用于我。 – 2012-03-12 03:39:48
我的歉意,请参阅我的编辑。在调用'.next()'之前,我的原始答案没有从'.col_5'到'.summary'。 – nnnnnn 2012-03-12 03:41:51
修订版现在完美运作。非常感谢@nnnnnn !!!! – 2012-03-12 03:45:27