Home  >  Article  >  Web Front-end  >  JQuery study notes element attribute control_jquery

JQuery study notes element attribute control_jquery

WBOY
WBOYOriginal
2016-05-16 18:49:21869browse
复制代码 代码如下:







无标题文档






123

在text表单中显示DIV的ID方法1
在text表单中显示DIV的ID方法2
在text表单中显示test2
去除inputTest2的value属性





1.element.attr(name)
Description: Used to get the name attribute value of an element. For example, $("#divTest").attr("id") in the example can get the ID of divTest value.
2.element.attr(name, value)
Description: Used to set the name attribute value of an element, such as $(":text").attr("value",$("# in the example) divTest").attr("id")) assigns the ID value of divTest to the value of the text form.
Note: In the example (":text") is used to obtain the elements whose input form type is text. The same method can be used to obtain other forms. For example, can use $( ":button") is used to obtain it, and its return value is Array(Element). You can also use $(":input") to obtain all input elements. . To get and set the text and value of an element in JQuery, you can also use element.text()/element.text(value), element.val()/element.val(Value), the usage is the same as element.html() , if you have any questions, you can leave a comment and I will explain it again

3.element.attr(name,function)
Description: Used to set the name attribute value of an element is similar to the previous one, except here The value can be written as a function, which is more flexible.
4.element.remove(name);
Description: Used to delete the name attribute of an element.
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