Reputation: 22705
Please look at this fiddle: http://jsfiddle.net/DHts6/1/
Why does it say undefined, even though the id = "foo"
is set!
Thanks
Upvotes: 0
Views: 3212
Reputation: 7713
$(document).ready(function(){
$('b.edit').click(function(){
$(this).hide().after('<form action = "foo.php" method = post><input name = "field" type = "text" value = "'+$(this).attr('id')+'"/><input type="text" name = "period" class="editP" value="'+$(this).html()+'" /><input type = "submit" value = "Submit!!" /></form>');
$('.editP').focus();
});
$('.editP').live('blur', function(){
$(this).hide().prev('b.edit').html($(this).val()).show();
});
});
Upvotes: 0
Reputation: 146302
Use this.id
not $(this).id
:
http://jsfiddle.net/maniator/DHts6/2/
Upvotes: 1
Reputation: 34150
You don't need $(this).id
, just do this.id
.
Reason for this is that $
creates a jQuery object that doesn't have .id
property. In jQuery you would use attr $(this).attr('id')
Upvotes: 4