javascript - Jquery .click() gives me "stack size exceeded" -
what in code gives me error?
jquery-2.1.3.min.js:3 uncaught rangeerror: maximum call stack size exceeded
html
<form id="addphotoform"> <img class="pull-right" src="" width="100px" height="140px"/> <input type="file" id="addphotoinput" name="addphotoinput" style="display: none;"/> </form>
js
//on click photo $('#addphotoform').on('click', function(){ //check if usrname exist var usrname = $('#usrname').val(); if(usrname){ $('#addphotoinput').trigger('click'); } else{ alert("!"); } })
how can solve error?
i'm trying open file dialog when clicking on form.
update
tried:
$('#addphotoinput').click();
to avoid click event handler bound using jquery fired, , still keep event propagation (useful if delegate click event bound too), call native dom click()
method instead:
$('#addphotoinput')[0].click();
or:
$('#addphotoinput').get(0).click();
which same as:
document.getelementbyid('addphotoinput').click();
Comments
Post a Comment