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:
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
from the method, and it is a getComputedStyle point that css() the jquery method cannot embody.ZXX: If you only know the jquery css () method, you won't know that pseudo-class styles are also available, although some browsers do not support them.For example, we want to get the height of an element, which can resemble
, return #bar position in all Li$ (' #bar '). index (); 1, does not pass the parameter, returns the index position of this element in the sibling. jquery get element index value () example For two-or three-level linkage $ ("#nav a"). Click (function () {Four classic usagevar index1 = $ ("#nav a"). Index (this);var index2 = $ ("#nav a"). Index ($ (this));var index
jquery gets the elements in two ways: the jquery selector, the jquery traversal function.1. Acquire itself:A. Only one jquery selector is required
Selector Selector
Instance
Description
#Id
$ (' #myId ')
ID selector: Can get to an
Jquery obtains the xy coordinate of an element. It uses the offset () method and sets the margin: 0; padding: 0; for details about how to obtain the absolute X of an element on the page, Y coordinate. You can use the offset () method: (the body property is set to margin: 0; padding: 0 ;)
Var X = $ ('# divid '). offset (). top; var Y = $ ('# divid '). offset
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
The following small series will bring you an article on jQuery to get the object elements (Implementation Code) of the current click ). I think it's quite good. Now I will share it with you and give you a reference. Let's take a look at it together.
JQuery gets the object element of the current click (implementation code)
Using JQuery, you can easily add, retrieve, and change the content of an HTML element. For this ease of use, let's take a look at the demo:
Welcome to PHP tutorial
PHP tutorial
Easy-to-understand JavaScript magic
Simple and easy-to-understand JQuery magic
The following small series will bring you an article on jQuery to get the object elements (implementation code) of the current click ). I think it's quite good. now I will share it with you and give you a reference. let's take a look at it together.
JQuery gets the object element of the current click (implementation code)
template element is optional. Because you can copy any existing element for loop.Next, add a repeat to each repeated element to facilitate the deletion button to find this level of element. This is optional and sometimes not required.The last step is to add a class to each
JQuery determines whether the element is displayed or hidden. For more information, see. Core code:
The Code is as follows:
If ($ ("# elem_id"). is (": hidden ")){}
Instance code 1:
The Code is as follows:
New Document
The preceding section describes how to use the $ function to filter elements on the page and replace onload events. $ Function also has a function. When its parameter is an HTML segment, it returns a package set containing this HTML element. For example:
The Code is as follows:
JQuery Wrapper
JQuery determines whether the element is displayed or hidden. For more information, see. Core code:
The Code is as follows:
If ($ ("# elem_id"). is (": hidden ")){}
Instance code 1:
The Code is as follows:
New Document
This article mainly introduces jquery's use of the hide method to hide the elements of a specified id. The example shows how to hide the elements of a specified id by hide in jQuery, which has some reference value, for more information about how to hide the elements of a specified id, see the example in this article. Share it with you for your reference. The details are as follows:
The following code uses jQuery's hide method to hide the id = test
This article mainly introduces jQuery's method of adding content before elements by using the prepend () method. The example shows how to use the prepend method to Append content, which has some reference value, for more information about how jQuery uses the prepend () method to add content before an element, see the example in this article. Share it with you for your reference. The specific analysis is as
This article mainly introduces jQuery's method of automatically hiding specified elements after a period of time. The example analyzes two commonly used techniques, which are very useful, for more information about how to hide a specified element, see the example in this article. Share it with you for your reference. The details are as follows:
The following code provides two methods to hide elements at regular intervals. The first method is setTim
You can dynamically add data on the page, such as a table. You can click the button to dynamically Add rows. Next I will share with you how jQuery obtains the dynamically generated element Requirement Description: You can dynamically add data on the page, for example, you can click the table button to dynamically Add rows. Or page
During loading, table data is obtained from the background through ajax. In t
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.