Detailed explanation of jQuery to get the value of special properties and set content

jQuery special attribute method

VAL method is suitable for setting and acquiring the value of the form element, such as the value of INPUT, TEXTAREA

// Gets the value of Name (“# name”). VAL (“); // Set the value of Name (” # name “). VAL (” Zhang San ”
   HTML method 
HTML method corresponds to InnerHTML, will recognize HTML tag

// Gets the value of content $ (“div”). HTML (“

Today is really good

    Text method  
TEXT method is equivalent to innerText, does not recognize HTML tag

// Get content value $ (“DIV “) .Text (); // Set the value of the content $ (” div “). Text (”

Today is really good


   InnerHTML and Innertext Difference   
InnerText prints text information between the label, filtering the label filtering and low version of Firefox browser does not support
InnerHTML print The content between the label includes tag and text information and each browser supports

Width method is the same as the method used by the Height method

$ (“img”). Width (200); // Set the width of the picture (“img”). WiDTH (); // Get the width of the picture; for example, obtain the aspect of the visible area (Window) .Width (); $ (window) .height ();

[Note] When the content of () is empty, the value of the acquisition content is empty. The value of the setting content is displayed when value value
  summary: Through this article, I want to learn how to get an element. The text value and set the text content, as well as the width and height of the visible area, I hope this article will help everyone's learning.  
© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment