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

Introduction to the usage of jQuery selector element

巴扎黑
Release: 2017-06-20 16:30:08
Original
1562 people have browsed it

Definition and usage

element selector selects elements with the specified tag name.

Tag nameQuote The text between the < and > 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;)
Copy after login

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);
Copy after login
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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template