This article mainly introduces the second parameter of the jQuery function to obtain the DOM element in the specified context. If you need it, you can refer to the second parameter of the jQuery function to specify the search range of the DOM element.
The second parameter can be divided into the following types:
DOM
JQuery exercises get objects (3)-Matching Based on attributes and content, and matching with form elements that contain id attributes, such as: $ ("span [id]")
The Code is as follows:
AAA BBB CCC DDD
EEE
FFF
If the specified element does not contain the id attribute, for example, $ ("span: not (span [id])") or $ ("span: not ([id])")
The Code is as follows:
AAA BBB CCC DDD
EEE
FFF
Contain
element to the page.$ (". A"). removeclass ("A") Remove$ ("#. A. B"). removeclass () Remove all elements$ (". A"). toggleclass ("B") Switch class
The element set obtained by $ (". A" ).html () takes the content of the first element by default. It can only be used in HTML and cannot be used in XML$ ("Ul" developer.html
How to obtain events on an element. jquery's events bound to the element can be retrieved using the data method. The following is an example, you can refer to jquery's events bound to elements and obtain them using the data method.
Use $ (element). data ("events") to obtain
// For example, bind two click events to a button $ ("button "). click (function () {ale
In ajax, you often need to precisely locate the position of an element. In this case, you not only need to obtain attributes such as the size and position of the element. You also need to know the length and width of the page, browser, and scroll bar. Because of browser compatibility issues, it is quite painful to obtain these values using javascript. Fortunately, JQuer
"Drag an element" as its name implies: drag, move, and drag. There are a lot of explanations, and there are a lot of related information on the Internet. I have also used this effect in the Development of AsyncBox. This is also a technical accumulation. This article mainly analyzes the drag-and-drop prototype and provides a simple example for fans who are new to JQuery.
After
Positioning is often used when developing jquery, including Positioning Relative parent elements and relative documents. This article summarizes that positioning is often required when developing jquery, here are two types of positioning:
1. Relative parent element positioning: $ ("# ele "). position () to obtain left = $ ("# ele "). postion (). left right = $
JQuery binds two click events (the second click event) to an element, and jquery binds
As required by the project, you need to set a style for the check box. The initial style is displayed when you click it for the first time, and the style needs to be changed when you click it for the second time :.
Design Concept:
When the number of clicks is an odd number,
This article mainly introduces how jQuery uses the empty () method to delete elements and all their child elements. It involves jQuery's element operation skills and has some reference value, for more information about how jQuery uses empty () to delete elements and all their child elements, see the following example. Share it with you for your reference. The spe
JRumble is a jquery plug-in that can shake the elements you choose. You only need one code for calling. Some of the jitter effects are cute, and the custom jitter effects are very cool. If you need them, you can refer to them. JRumble, which can shake up any element on the webpage. Using this effect on your website will have a high chance of attracting users' attention. The effect of this plug-in can be use
This article mainly introduces jQuery's method of adding multiple content after using append in the html element. The example shows how to use append content in jQuery, which has some reference value, for more information about how jQuery uses append to add multiple content after html elements, see the example in this article. Share it with you for your reference
Article Introduction: jquery wrapper function to achieve the advantages of the array element paging effect.
The advantage of using jquery's $ () wrapper function to achieve the paging effect of array elements
In the last week in the Chinese station to search for the needs of the gift widget, this requirement has a paging function; Specific demo can see the following figure:
(as s
Align: Left-right alignment; vlign: vertical alignment; xleft: horizontal replenishment value; xleft: vertical replenishment value; adjust: whether to adjust automatically relative to the window; rwindow: Positioning Relative to the window (align amp; vertical or horizontal center when vlign is set to center)
The Code is as follows:
/*** JQuery rposition* Fix: the element to be located.* Rel: relative p
This article mainly introduces how to use jquery. each () traverses the element learning notes. This article summarizes from the actual project experience. If you need it, you can refer to the section in jquery when writing a tab today. each (): Obtain the ID of the li element by obtaining the index parameter in each (
jquery Gets the parent element method is more, such as parent (), parents (), closest () These can help you to find the parent element or node, let us one by one to explain:Let me give you an example:ulclass= "Parent1"> Li>ahref="#"ID= "Item1">jquery Gets the parent nodea>Li> Li>ahref="#">
Preface: This is the category of the blog, jquery is the beginning of the search. Because checking the manual is too cumbersome, and sometimes you need to drill down into the detail page of the command to see what the purpose of this command is. Write this article is to, work encountered problems, a look at these articles can find out which command is exactly in line with the role, and then go into the manual for specific learning usage. The writing i
JQuery is still very convenient to get the index value of the current element. For example, there are a lot of li resources. When the mouse moves up, do you know the number of li resources? JavaScript code
$ ("Li"). hover (function () {alert ($ ("li"). index (this ));}); [Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
The. index function is still very
To delete an HTML element, you can use remove and empty. The following describes how to use these two methods to delete or clear an HTML element.
Remove ()-delete a specified Element (including its child elements)Empty ()-clears child elements of a specified Element
For example:
This article describes how to use jquery to remove, bind, and trigger element events. For more information, see
The Code is as follows:
Unbind (type [, data]) // data is the function to be removed$ ('# Btn'). unbind ("click"); // remove the click$ ('# Btn'). unbind (); // remove all
If you only need to trigger the binding once and then immediately unbind it, use one ()
The Code is as follows:
$ ('# Btn'
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.