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
function.
Looking at a simple example, the HTML code still uses the above:
Copy code The Code is as follows:
Result: To delete an attribute, use the removeattr (name) method.Note that there is a special attribute class in the attribute. Class attributes are very common, and they happen to be JavaScript keywords. To access the class attribute, you must use c
jquery filter Element functions1. FilteringMatch the second P element:$ ("button"). Click (function () {$ ("P"). EQ (1). CSS ("Color", "red");});Match the first LI element:$ ("button"). Click (function () {$ ("Li"). First (). CSS ("Color", "red");});Match the last element:$
Click the page to obtain the id or other information of the currently clicked element. jquery can be used to easily achieve this. The following is a good example and I hope it will be helpful to you.
The Code is as follows:
$ (Document). click (function (e ){Var v_id = require (e.tar get). attr ('id ');}
The Code is as follows:
Certificate (e.tar get)
The tag name is available for the current
The property of the tag is called the element attribute, and the corresponding property of the DOM object in JS is called the DOM attribute. The DOM attribute name in JS is sometimes different from the original element property name.1 2 //return element specify attribute value3 vartxt1_val=$ ("#txt1"). attr ("value");4 //Change DOM property value by the DOM prope
1. Operation "Element Properties"We can use GetAttribute and setattribute in JavaScript to manipulate element attributes of elements.In jquery, you are provided with a attr () wrapper set function that allows you to manipulate the attributes of all the elements in the wrapper set:
Name
Description
Example
attr (name)
Get
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:
The corresponding JS application file is the same, the page after the offer data has been buried, just enabled the CSS Display:none style to hide behind the offer elements. It is now required to implement a page-by-page effect on existing pages elements, that is, the page element col
This article is a common element in jquery in the search method for a detailed summary and introduction, the need for friends to refer to the
$ ("#myELement") select an element with an ID value equal to MyElement, and the ID value cannot be repeated in the document only one ID value is myelement so the unique element
value of its name to the return value of the function.
To see a simple example, the HTML code still uses the above:
Copy Code code as follows:
The results are:
To delete a property, use the Removeattr (name) method.
Note that there is a special attribute class in the attribute. Class attributes are very common, and he happens to be the keyword of JavaScript. To access the
The following 2 kinds of situations are divided:
1. If the CSS is written in inline style, you can judge by getting the value of the Style property, as shown in the following example:
Determine if the DIV element with ID divID has a font-size style:
Copy Code code as follows:
The jquery code is as follows:
JQuery ("#divid"). each (function () {
Let's look at one example:
Copy Code code as follows:
Copy Code code as follows:
JQuery ("#easy"). Click (function () {
Alert (document.getElementById ("Easy"). ID); 1
alert (this.id); 2
Alert (JQuery (this). attr ("id")); 3
});
Method 1 uses the JavaScript primitive method, and Method 2 uses This,this as a pointer, returning a DOM object, in this cas
$ (function () {
//traversal gets array of INPUT element objects, binding Click event
var len = $ ("input[type= ' file ']"). Length;
for (var i = 0; i
jquery Fetch:
Jquery.parent (expr), looking for the Father node, can be passed in expr for filtering, such as $ ("span"). Parent () or $ ("span"). Parent (". Class")
Jquery.parents (expr), similar to
summary, see http://docs.jquery.com/Effects/animate
The following is an example. the id is "note" div. calling animate () triggers the click () event of the jQuery library by clicking.
$ Params = array ('Height' => 80,'Width' => '123 ','Marginleft' = gt; 125);$ This-> jquery-> click ('# trigger', $ this-> jquery-> animate (' # note', $ params, normal ));FadeIn
jquery element Selection, common methods
One: The commonly used selector:
Base Selector $ ("#myDiv")//Match unique element $ ("div") with this ID value///Match all elements of the specified name $ (". MyClass")//Match all elements with this class style value $ ("*")//Match all elements $ (this)//horse With its ow
Recently learning jquery, found that its selector of the wording of the CSS and the basic syntax is very similar, plus the space difference is very large.$ (": first-child)--:first simply returns a single element, and the First-child selector matches the first child element for each parent element.
such as child
JQuery Learning 6 Deleting an elementLast lesson we did add elements, the simulation is the landlord hair articles, passers-by comments, then the students learned this lesson after the deletion, go to the previous code to add a delete, mock a landlord delete passers-by comments. How to delete jquery:
Remove ()-Deletes the selected element (and its child
The selector does not have a fixed definition, and in some ways the jquery selector is very similar to the selector in the style sheet. Selectors have the following characteristics:
1. Simplifying the writing of code
2. Implicit iterations
3. No need to determine if an object exists
The JQuery selector is incredibly powerful, and here's a quick summary of common ele
$ ( Quot; # myELement quot;) Select the element whose id value is myElement, the id value cannot be repeated. Only one id value in the document is myElement. Therefore, the unique element $ ( quot; div quot;) is obtained. All div tag elements are selected, returns the div element array $ ( quot ;. myClass quot;) Select myClass
$ ("# MyELement") Select the
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.