下面,我有一段javascript代碼。在javascript中的var修改問題
var htmlBlurb = '<div> hello <font color=red>world</font>!!!</div>';
$(htmlBlurb).find('font').each(function(e){
$(this).html("Javascript");
});
console.log(htmlBlurb);
我期待在htmlBlurb輸出作爲
<div> hello <font color=red>Javascript</font>!!!</div>
但htmlBlurb
沒有改變。
有人可以解釋我在這裏錯過了什麼嗎?
你永遠保存的'$結果(htmlBlurb)''來htmlBlurb',因此它只是一個字符串 –
請不要使用''元素;它在一段時間前被棄用。 – j08691
但他們用'