First of all, the method of JS acquisition, which is more troublesome than the jquery method, followed by the jquery method for comparisonJS is a lot more troublesome than jquery, mainly because the FF browser, the FF browser, will take your newline as the most DOM element.Native JS Gets the child element under the
First of all talk about the acquisition of JS, which is much more cumbersome than the jquery method, followed by the jquery method for comparison
JS method is much more troublesome than jquery, mainly because the FF browser,FF browser will be your line of exchange as the most DOM element
Native JS Gets the child
Recent work has always encountered a variety of father Ah son Ah brothers and sisters Ah, every time to check, this time to organize a internationals ~
First, we'll have dry goods:
"JS access Mode"
"How jquery is captured."
Jquery.parent (expr) for the Father node, you can filter through expr, such as $ ("span"). Parent () or $ ("span"). Parent (". Class")
jquery.parents (expr , simi
Recently work has always encountered to take all kinds of Father son Ah brothers and sisters Ah, every time to check, this time to tidy up a internationals ~"How to Get JS"function dom () {var a = document.getelementbyidx_x_x ("Dom");var B = a.childnodes; Get all child nodes of avar c = A.parentnode; Gets the parent node of avar d = a.nextsbiling; Get the next si
First, get the parent element
1. Parent ([expr]):
Gets all the parent elements of the specified element
Copy Code code as follows:
$ (document). Ready (function () {
$ ("a"). Parent (). addclass (' A_par ');
});
Firebug View jquery Parent Effect
Second,
Currently several borrowing jquery Select click Element to get the current click Element Information,$ (document). Click (function (e) {//) to trigger this event at any point in the page ( e.target). attr ("id"); E.target = clicked Target})This method is needed to obtain the current Click
Summarize:child element selectors in pseudo-classes:The first type:: First-child: Last-child: Nth-child (): Nth-last-child ()The second type:: Only-child: Only-of-typeThe third type of:: First-of-type: Nth-last-of-type (): Nth-of-type ()Characteristics:Pseudo-class selectors are very characteristic:1. Position: Directly through the pseudo-class selector directly
Iframe is often used in web development, and elements that need to be used in the iframe in the parent window or in the iframe framework
JsObtain the elements in IFRAME in the parent window. 1,Format: window. frames ["iframe name value" 2.16.doc ument. getElementByIdx_x ("Control ID in iframe"). click ();Example: window. frames ["ifm" mirror.doc ument. getElementByIdx_x ("btnOk"). click ();2,Format:Var obj = document. getElementByIdx_x ("iframe name"). contentWindow;Var ifmobj1_obj.doc ument. ge
This article mainly introduces the sample code for JS and JQUERY to get the page size, scroll bar location, and element location. For more information, see. js and jquery.
The Code is as follows:
// Page location and window size
Function GetPageSize (){Var scrW, scrH;If (window. innerHeight window. scrollMaxY){// Mo
Get one of the matching elements: index means to get the first few matching elements, which allows you to select an actual DOM element and manipulate it directly, rather than through the JQuery function. $ (this). Get (0) is equivalent to $ (this) [0],The meaning of this pas
get the parental element, so getting the parent of an element can use the
$ (selector). Parent (). parent ();
Example below
Creating HTML code and CSS styles
Class1Class2Class3
div{padding:10px 20px;border:4px solid #ebcbbe;}div.class1{width:200px;height:120px;}
Writing jquery Code
$ (function () {$ ("DIV.CLASS
How does jquery get the first or last child element? Through the Children method, children ("Input:first-child")$( This). Children ("Input:first-child"). Val (); $ ( This). Children ("Input:last-child"). Val ();> Selector, $ (". Items>input:first"in this article, we'll turn to a "jquery selection method Encyclopedia" h
This article mainly introduces how to obtain the code of a specific sub-element in jquery. If you need it, you can refer to some JQUERY applications that have been made earlier, the selector does not have high requirements, like "$ ('. class ') "," $ (' # id') "," $ ('# id>. class
x here can only be one element, and the x in the above sentence is an Array, you can convert and process it yourself.
Var y = Ext. get (x );
Next, we need to introduce the QueryStr format (in fact, it is similar to the selector format in jQuery). As for what you can do after getting the Element, let's take a look at E
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
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 c
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 c
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
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.