asp.net - The jquery keyup event is not working -


i working on making sharepoint 2007 app more modern. using jquery actively , though no expert, have learnt enough know ways around. untill faced issue today. here bits:

  $(document).ready(function() {     alert('doc ready');     var textbox1 = $("#mytest");     alert(textbox1);      textbox1.keyup(function() {         alert('key up');     });      textbox1.live("keyup", function() {         alert('keykeykey live');     });  }); 

server-generated html:

    <input name="ctl00$spwebpartmanager1$g_1f2d211c_a0c3_490d_8890_028afd098cac$ctl00$mytest" type="password" id="ctl00_spwebpartmanager1_g_1f2d211c_a0c3_490d_8890_028afd098cac_ctl00_mytest" class="gh" /> 

so document ready handler fires, textbox1 variable not null, none of eventhandlers handle keyup event ever fire? mind reels...

i doesn't work because id attribute actaully ctl00_spwebpartmanager1_g_1f2d211c_a0c3_490d_8890_028afd098cac_ctl00_mytest

try

var textbox1 = $("input[id$='_mytest']");

here looking html input field has id attribute ends string _mytest

in future debugging use

alert(textbox1.length)

so can whether jquery object empty or not. if selector doesn't find return empty jquery object isn't null. can test whether selector found making sure .length property positive.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -