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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -