lindm Posted January 23, 2010 Share Posted January 23, 2010 My code below only executes once. So after first click and I remove text from the textfield manually and click the + nothing happens. It should work whenever clicked. <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script type="text/javascript" > $(document).ready(function(){ $("*[id^=\'ST\']").each(function() { $(this).click(function() { string = this.id.substring(2); string2 = "#" + string; $(string2).load('tips/'+this.id+'.txt'); }); }); }); </script> </head> <body> <a id="STtextfield">[+]</a> <textarea name="textfield" id="textfield"></textarea> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/189553-jquery-function-only-executes-once/ Share on other sites More sharing options...
lindm Posted January 24, 2010 Author Share Posted January 24, 2010 When I change to jquery 1.3.2 it works no matter how many times I click the + sign. Is it a bug in 1.4? Quote Link to comment https://forums.phpfreaks.com/topic/189553-jquery-function-only-executes-once/#findComment-1000720 Share on other sites More sharing options...
lindm Posted January 24, 2010 Author Share Posted January 24, 2010 Using this instead... $(document).ready(function(){ $("*[id^=\'ST\']").click(function() { string="#"+this.id.substring(2); $.get("tips/"+this.id+".txt", function(data){ $(string).val(data); }); }); }); Quote Link to comment https://forums.phpfreaks.com/topic/189553-jquery-function-only-executes-once/#findComment-1000851 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.