我有這樣的HTML的標記:的jQuery,前置數據
<div id="destination">
</div>
<input id="test" type="text" />
<button id="clicker">Click me</button>
這jQuery的片段
$(document).on('click', '#clicker', function(event){
var newCat = $('#test').val();
$(newCat).prepend("#destination");
alert(newCat);
});
的警告文字確實是在該領域在輸入的文本,但文本不會以div #destination
結尾。
看到這個的jsfiddle例如: http://jsfiddle.net/FaAY4/
你爲什麼要委託的事件'document'? –