Jquery $of this.attr $of this.val method

  • 2020-03-26 21:22:38
  • OfStack

$(this). Attr (key); Gets the value of the node attribute name, equivalent to the getAttribute(key) method

$(this). Attr (key, value); Sets the value of the node attribute, equivalent to the setAttribute(key,value) method

Eg: < Div id = "w_1" class = "widget" diywidgetid = "${template. Diywidgetid}" > < / div>

Var diywidgetid = $(' # w_1). Attr (' diywidgetid '); // gets the value of the node property

$(this). Val (); Gets the value of an element node, equivalent to $(this).attr(" value ");

$(this). Val (value); Set the value value of an element node, equivalent to $(this).attr(" value ",value);

Eg: < Input the id = "i_eg" value = "1" type = "text" > < / input>

Var i_eg = $(' # i_eg). Val (); // gets the value of the element node

Related articles: