Summary of jquery selector and attribute setting usage experience_jquery
WBOYOriginal
2016-05-16 17:23:161370browse
I am a novice and a fresh graduate. I have never used jquery before. I recently used jquery in a project. In the process of doing it, I took many detours and kept searching. Some usages are summarized for your reference:
The most basic selector syntax includes: id, class, label, attribute, which is consistent with css selector.
The ID selector should add # before the ID. For example, if you want to select a div element with the ID myDivID (
D cannot be repeated, so the ID selector selects a jquery object.
The class selector should add a dot (.) before class. For example, if you want to select an input element with class myInputClass (), you can write like this:
class can be repeated, so the class selector can select one type of elements, that is, multiple elements, so jquery selects an array, and you can select each element by referring to the subscript: for example
The tag selector is also selected An array, select all p tag elements, you can also use the above method to iterate out all elements.
Attribute selectors should be preceded by square brackets ([]). For example, if you want to select elements with name="xxName", you can write like this:
Select in this way, and the result will be the same An array because name can be repeated.
The ID selector can accurately select an element, but in development we may have to select a group of elements more. How can we accurately select the elements we want? In fact, there are several Selectors can be mixed:
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