jquery學習之二屬性(html()與html(val))_jquery
來源:懂視網
責編:小采
時間:2020-11-27 20:55:56
jquery學習之二屬性(html()與html(val))_jquery
jquery學習之二屬性(html()與html(val))_jquery:html() 取得第一個匹配元素的html內容。這個函數不能用于XML文檔。但可以用于XHTML文檔。 Get the html contents of the first matched element. This property is not available on XML documents (although it
導讀jquery學習之二屬性(html()與html(val))_jquery:html() 取得第一個匹配元素的html內容。這個函數不能用于XML文檔。但可以用于XHTML文檔。 Get the html contents of the first matched element. This property is not available on XML documents (although it

html()
取得第一個匹配元素的html內容。這個函數不能用于XML文檔。但可以用于XHTML文檔。
Get the html contents of the first matched element. This property is not available on XML documents (although it will work for XHTML documents).
返回值
String
示例
代碼如下:
HTML 代碼:
Hello
jQuery 代碼:
$("div").html();
結果:
Hello
html(val)
設置每一個匹配元素的html內容。這個函數不能用于XML文檔。但可以用于XHTML文檔。
Set the html contents of every matched element. This property is not available on XML documents (although it will work for XHTML documents).
返回值
jQuery
參數
val (String) : 用于設定HTML內容的值
示例
代碼如下:
HTML 代碼:
jQuery 代碼:
$("div").html("
Hello Again
");
結果:
[
Hello Again
]
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
jquery學習之二屬性(html()與html(val))_jquery
jquery學習之二屬性(html()與html(val))_jquery:html() 取得第一個匹配元素的html內容。這個函數不能用于XML文檔。但可以用于XHTML文檔。 Get the html contents of the first matched element. This property is not available on XML documents (although it