我有从未执行的jQuery代码。当我在浏览器控制台中尝试使用相同的代码时,它的工作原理,所以我不明白为什么我的代码从未执行。jQuery代码从未执行
HTML代码:
<div id="ans">
<label>{$valeur}</label>
<div class="radio">
{foreach $reponse as $ligne}
<input type="radio" name="answers" id="answer_{[email protected]}" value="{[email protected]}"/><label for="answer_{[email protected]}">$ligne</label><br />
{/foreach}
</div>
</div>
更新:
document.addEventListener("DOMContentLoaded", function() {
setTimeout(function(){
$.post(ajax_path+"bla.php", {} , function(response) {
$('#quest').html(response);
$('#quest').collapse("show");
})
.fail(function(jqXHR, textStatus, errorThrown) {
{/literal}
toastr.error(__['Error'], __['Error']);
{literal}
});
}, 50);
$('input[name=answers]').on('change', function() {
$(this).closest("form").submit();
});
});
你jQuery可能会在'DOMContentLoaded'之后加载。使用'$(document).ready' –
为什么你以这种方式混合使用vanilla JS和jQuery? –
已经尝试过,它不起作用。 – Mulan