Acquiring content label

1. Elemental .innerText js Gets or sets the text label

var Box = document.getElementById ( ' Box ' ) 
box.innerText = ' are void '
var box=document.getElementById('box')
console.log(box.innerText )

2. Elemental .innerHTML js set or acquire content tag (HTML tags)

var Box = document.getElementById ( ' Box ' ) 
box.innerHTML = ' <P> ha </ P> '
var box=document.getElementById('box')
console.log(box.innerHTML )

3. element .value js provided or acquired form field value

var Box = document.getElementById ( ' Box ' ) 
box.value = " Soymilk "
var box=document.getElementById('box')
var bt=document.getElementById('bt')
bt.onclick=function(){
console.log(box.value)
}

4. element .val () jquery Gets or sets the value of the form field

$ ( ' #Box ' ) .val ( ' videophone ' )
$('#bt').click(function(){
  console.log($('#box').val())
})

5. Element .html () jquery Gets or sets the contents of the selected elements (HTML tags)

$ ( ' #Box ' ) .html ( ' <P> ha </ P> ' )
$('#bt').click(function(){
  console.log($('#box').html())
})

6. element .text () jquery Set or get the text content of the selected element

$ ( ' #Box ' ) .text ( ' ha ' )
$('#bt').click(function(){
  console.log($('#box').text())
})

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/zhaodz/p/11618215.html
Recommended