Javascript 在html/jQuery中单击两次已注册
我用不同的id打印了几次HTML部件代码(Javascript 在html/jQuery中单击两次已注册,javascript,html,jquery,css,laravel,Javascript,Html,Jquery,Css,Laravel,我用不同的id打印了几次HTML部件代码(${element.id}在每个部件中它们都是不同的)。现在,第一个子元素工作正常,但其他子元素注册了两次单击(在单击其淡入和淡出后)。我想删除这个错误。我使用Laravel作为主要框架。对不起,我的英语:) 提前感谢 <div class="notification warning closeable" id="checkbox-area"> <input type="checkbox" name="blocks[]" class="
${element.id}
在每个部件中它们都是不同的)。现在,第一个子元素工作正常,但其他子元素注册了两次单击(在单击其淡入和淡出后)。我想删除这个错误。我使用Laravel作为主要框架。对不起,我的英语:)
提前感谢
<div class="notification warning closeable" id="checkbox-area">
<input type="checkbox" name="blocks[]" class="form-check-input" id="element${element.id}" value="${element.url}" checked>
<label class="form-check-label" for="element${element.id}">${element.name}
<img src="${window.location.origin}/${element.thumbnail}" id="original" class="imgBlocks">
</label>
<button class="dropbtn" data-id="${element.id}" type="button">...</button>
</div>
<div class="drop-down" id="drop_${element.id}">
<div id="text-generation" class="drop-down-text">
</div>
<button type="button" id="btn-text-updater">new text</button>
</div>
您应该更改:
if ( $("#drop_"+id).is(":visible") ) {
$("#drop_"+id).fadeOut(1000);
} else {
$("#drop_"+id).fadeIn(1000);
}
到
同样的事情。没什么变化你能写一个更完整的代码吗?这似乎是其他原因造成的。
if ( $("#drop_"+id).is(":visible") ) {
$("#drop_"+id).fadeOut(1000);
} else {
$("#drop_"+id).fadeIn(1000);
}
if ( $("#drop_"+id).is(":visible") ) {
$("#drop_"+id).fadeOut(1000);
return;
}
$("#drop_"+id).fadeIn(1000);