Jquery commonly used SET and GET$of 'hash MSG'. HTML loop introduction

  • 2020-03-26 21:21:23
  • OfStack

 
$( " #msg " ).html(); //Returns the HTML content of the element node with an id of MSG.
$( " #msg " ).html( " new content " ); 
//Write "new content" as an HTML string into the element node content with id MSG, and the page displays new content in bold

$( " #msg " ).text(); //Returns the text content of the element node with id MSG.
$( " #msg " ).text( " new content " ); 
//Write "new content" as a plain text string to the content of the element node with id MSG, and the page displays new content

$( " #msg " ).height(); //Returns the height of the element with id MSG
$( " #msg " ).height( " 300 " ); //Set the height of the element with id MSG to 300
$( " #msg " ).width(); //Returns the width of the element with id MSG
$( " #msg " ).width( " 300 " ); //Set the width of the element with id MSG to 300

$( " input " ).val( " ); //Returns the value of the form input field
$( " input " ).val( " test " ); //Set the value of the form input field to test

$( " #msg " ).click(); //Triggers the click event for the element with the MSG id
$( " #msg " ).click(fn); //Add a function for the element click event with an id of MSG

$.each( [0,1,2], function(i, n){ alert( "Item #" + i + ":" + n );}); 
[code] 
 Is equivalent to:  
[code] 
vartempArr=[0,1,2]; 
for(vari=0;i<tempArr.length;i++){ 
alert("Item#"+i+":"+tempArr[i]); 
} 

Related articles: