Home  >  Article  >  Web Front-end  >  Introduction to the usage of jQuery selector element

Introduction to the usage of jQuery selector element

巴扎黑
巴扎黑Original
2017-06-20 16:30:081484browse

Definition and usage

element selector selects elements with the specified tag name.

Tag nameQuote The text between the 709755eb0d440af414163d2e5288b1b1 of the HTML tag.

Syntax

$(tagname)

Parameters                 Description

tagname         required. Specifies the name of the element to be selected.

Under IE and Firefox, the methods of dynamically creating elements are different.

The following code can be run under IE, but an error will be reported under Firefox

 var theform = document.forms[0]; theform.appendChild(document.createElement("<input type=&#39;hidden&#39; name=&#39;EVENTTARGET&#39;>"));
在 Firefox 只支持:document.createElement(&#39;input&#39;)

If If you add attributes and events, you need to use the setAttribute method

Use jquery to dynamically create elements, which can support IE and Firefox

 var theform = document.forms[0];
  $("<input type=&#39;hidden&#39; name=&#39;EVENTTARGET&#39;>").appendTo(theform);
at the same time

The above is the detailed content of Introduction to the usage of jQuery selector element. For more information, please follow other related articles on the PHP Chinese website!

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