我的页面中有以下 JQuery。该页面加载正常,并且代码最初可以正常工作。如果我编辑 textarea 字段,再次单击该字段将不起作用。即使在编辑 textarea 之后,有没有办法绑定 JQuery 功能?
$(document).ready(function() {
$("#prop_notes").dblclick(function() {
var timestamp = '2013-04-01 20:40:00';
var userid = '1';
var username = 'Jim Williams';
if ($('#prop_notes').val() == '') {
$("#prop_notes").text("Timestamp: " + timestamp + "\nUser ID: " + userid + "\nUser: " + username);
}
else {
$("#prop_notes").text($("#prop_notes").text() + "\n\n- - - - - - - - - - - - - - - - - - - -\n\nTimestamp: " + timestamp + "\nUser ID: " + userid + "\nUser: " + username);
}
});
});
可重现的行为小提琴:http: //jsfiddle.net/njgray/MxPNX/1/