$("#write").click(function(){
$("#msg").$('#quote').html();
});
我正在學習jquery(js也是新的)。這個函數寫入一個文本框id = msg。不過,我在抽取內容時遇到問題。不知道如何在jQuery中使用變量
如何拉取div的內容並在我的函數(#quote)中使用?現在它只是寫#quote,而不是名爲quote的div的內容。
也試過:
var quote = $("#quote").html();
$("#msg").$(quote.val).html();
的想法。
+1有更多解釋,並且快9秒! – JCOC611
非常感謝,我非常接近。所以創建一個新的變量是我猜測的唯一方法嗎? – domino
@Dvir:+1打我9秒;)@domino:你不必創建一個新的變量。您可以使用:'$('#msg')。html($('#quote')。html());' –