LoginSignup
0
2

More than 3 years have passed since last update.

【jQuery】.text()と.html()の違い

Posted at

サンプル

キャプチャ.PNG

説明

$elm.text()

$elmの子孫要素のテキストノードのみ取得。
タグは取得しない。

$elm.html()

$elmの子孫要素の全てHTMLを取得。
タグも取得する。

$elm.text(str)

$elmにstrをテキストノードとして設定。
タグは反映されない。

$elm.html(str)

$elmにstrをHTMLとして設定。
タグは反映される。

参考

jQueryのtext()とhtml()の違い

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2