コンテンツラベルの取得

1.エレメンタル.innerText JSは、テキストラベルを取得または設定します

VaRのボックス=のdocument.getElementById(' ボックス' 
box.innerText =は' 無効です'
VaRのボックス=のdocument.getElementById(' ボックス' 
はconsole.log(box.innerText)

2.エレメンタル.innerHTML jsのセットやコンテンツタグ(HTMLタグ)を取得

VaRのボックス=のdocument.getElementById(' ボックス' 
box.innerHTML = ' <P>ヘクタール</ P> '
VaRのボックス=のdocument.getElementById(' ボックス' 
はconsole.log(box.innerHTML)

3.要素.VALUEを提供または取得したフォームフィールドの値をJS

VaRのボックス=のdocument.getElementById(' ボックス' 
box.value = " 豆乳"
VaRのボックス=のdocument.getElementById(' ボックス' VAR BT =のdocument.getElementById(' BT ' 
bt.onclick = 関数(){ 
にconsole.log(box.value)
}

4.要素.val()jQueryのフォームフィールドの値を取得または設定します

$(' #Box ').val(' テレビ電話'
$(' #bt ' ).click(関数(){ 
  にconsole.log($(' #box ' ).val())
})

5.要素の.html()jQueryのは、選択された要素(HTMLタグ)の内容を取得または設定します

$(' #Box ').htmlを(' <P>ヘクタール</ P> '
$(' #bt ' ).click(関数(){ 
  にconsole.log($(' #box ' )の.html())
})

6.要素の.text()jqueryのは、設定または選択された要素のテキストの内容を取得します

$(' #Box ')の.text(' HA '
$(' #bt ' ).click(関数(){ 
  にconsole.log($(' #box ' )の.text())
})

 

 

 

 

 

 

おすすめ

転載: www.cnblogs.com/zhaodz/p/11618215.html