Jump to content

Jquery: Function only executes once


lindm

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.