如何在Jquery中选择下一个标记
如何显示下面的表格 HTML如何在Jquery中选择下一个标记,jquery,Jquery,如何显示下面的表格 HTML <p><input type ="button" id="comment16" value="Comment"></p> <div class="form" style="display:none"> 即使警报显示正确的id,我的脚本也无法工作。请使用下面的代码 $('[id^="comment"]').click(function(e) { $(this).parent().next('.f
<p><input type ="button" id="comment16"
value="Comment"></p>
<div class="form" style="display:none">
即使警报显示正确的id,我的脚本也无法工作。请使用下面的代码
$('[id^="comment"]').click(function(e) {
$(this).parent().next('.form').show();
});
jQuery::next
查找同级。表单div不是输入按钮的同级;它是输入按钮父级的同级。您需要更改代码以引用父级的同级
$('[id^="comment"]').click(function (e) {
var $thisClicked = $(this);
var $nextForm = $thisClicked.parent().next('.form');
$nextForm.show();
});
谢谢,对不起,我是初学者。
$('[id^="comment"]').click(function() {
$(this).closest('p').next('.form').show();
});
$('[id^="comment"]').click(function (e) {
var $thisClicked = $(this);
var $nextForm = $thisClicked.parent().next('.form');
$nextForm.show();
});