jQuery code never executed -


this question has answer here:

i have jquery code never executed. when i'm trying same code in browser console works, don't understand why code never executed.

html code :

<div id="ans">      <label>{$valeur}</label>      <div class="radio">          {foreach $reponse $ligne}              <input type="radio" name="answers" id="answer_{$ligne@iteration}" value="{$ligne@iteration}"/><label for="answer_{$ligne@iteration}">$ligne</label><br />          {/foreach}      </div> </div> 

update :

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();     }); }); 

$(function() {      $('input[name=answers]').change(function() {          $(this).closest("form").submit();     });  }); 

try this

also, make sure selector correct

edit

when want execute when of page contents loaded can use load instead of ready

something this

$(document).load(function() {      $('input[name=answers]').change(function() {           $(this).closest("form").submit();      });  }) 

also, can use window instead of document also


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -