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> 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? 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); }); }); }); 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
Archived
This topic is now archived and is closed to further replies.