Home >Web Front-end >JS Tutorial >jquery $(this).attr $(this).val method introduction_jquery

jquery $(this).attr $(this).val method introduction_jquery

WBOY
WBOYOriginal
2016-05-16 17:20:321215browse

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

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

eg:



var diywidgetid = $('#w_1').attr('diywidgetid'); //Get node attributes The value of

$(this).val(); gets the value of an element node, equivalent to $(this).attr(“value”);

$(this) .val(value); Set the value of an element node, equivalent to $(this).attr(“value”,value);

eg:

var i_eg=$('#i_eg').val(); // Get the value of the element node
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn