我遇到了一些CSS + javascript的問題。你看,我試圖做一些wysiwyg網頁風格編輯器,其中有一個iframe加載一個包含這樣的代碼的網頁。jQuery,編輯內聯樣式標記
<head>
<style id=mystyle>
/* something is here */
</style>
</head>
<body>
<h1>Other, quite a lot autogenerated stuff along with javascript that add some interactivity.</h1>
</body>
現在,我需要修改#mystyle的內容,以便它實時反映到頁面中。使用jQuery,我試圖做這樣使用多種技術,如:
$(#mystyle).html(newcss);
$(#mystyle).replaceWith("<style id='mystyle'>"+newcss+"</style>")
$(#mystyle).after("the newcss along with style tag")
,然後刪除舊的。$(#mystyle).delete()
//只是爲了看看會發生什麼。
上述所有未能改變網頁的外觀。事實上,刪除標籤(4.)並沒有使頁面變得難看,而且我使用「Inspect Element」進行了檢查,但html確實發生了變化,但外觀沒有改變。所以......我做錯了什麼?
怎麼樣幫助我們了上jsfiddle.net – Dhiraj