答案 0 :(得分:4)
您不需要$(this).id
,只需执行this.id
。
原因是$
创建了一个没有.id
属性的jQuery对象。在jQuery中,您可以使用attr $(this).attr('id')
答案 1 :(得分:1)
使用this.id
不 $(this).id
:
答案 2 :(得分:0)
$(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();
});
});