javascript - JQuery, get input id -


<script>     $(document).ready(function() {         $('#hotelo_div :input').onblur = validate(1, this.id, "abcd");     }); </script>  <div id="hotelo_div">     <table id="hotcalcmain">         <tr>             <td>pmi1</td>             <td class="hotcc"><input type="text" id="pmi_1" maxlength="2" size="2"> %</td>             <td class="hotcc"><input type="text" id="pmi_2" maxlength="2" size="2"> %</td>             <td class="hotcc"><input type="text" id="pmi_3" maxlength="2" size="2"> %</td>             <td class="hotcc"><input type="text" id="pmi_4" maxlength="2" size="2"> %</td>         </tr>         ... 

how send input id(e.g. pmi_1, pmi_2, ...) function validate parameter @ posiont "this.id"?

$('#hotelo_div :input').onblur should assigned function reference rather returned value of function. this not point input here. if using jquery, can use jquery event handlers itself.

replace line

$('#hotelo_div :input').onblur = validate(1, this.id, "abcd"); 

with

$('#hotelo_div :input').blur(function(){   validate(1, this.id, "abcd"); })  

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -