I am using Jquery to create dynamic links based on user input. I have a set of elements in my ajax loaded div that looks like this
<div class="mxcell">
<input type="text" size="40" class="input_name" value="">
<a href="#" target="_blank" class="dyn_link">
<img src="http://127.0.0.1/images/arrow_right.gif">
</a>
</div>
Now in Jquery I write
$(function(){
$("#right").delegate(".input_name", "change", function(){
var dyn_link = $(this).val()
$(this).parent().find("a").attr("href", "http://www.example.com/"+ dyn_link +".html");
});
}开发者_如何学Go);
This works fine in Chrome/Firefox, but not in Internet Explorer.
Any ideas?
IE debugger pointed to Jquery line 69 character 15. Wouldn't know to investigate it further.
UPDATE:
I solved the above by using focusOut() instead of change()
But am not still sure whether there is a better solution
http://jsfiddle.net/pNZTe/
I'd keyup
instead of focusOut
, and I cleaned up your href changer a bit:
$("#right").delegate(".input_name", "keyup", function() {
var $this = $(this);
var dyn_link = $this.val();
$this.next("a").attr("href","http://www.example.com/" + dyn_link + ".html");
});
精彩评论