Sharp Jquery--jquery and DOM object conversion, Dom three operations (reading note one)

Source: Internet
Author: User

a 1.jQuery object is an object that is created after wrapping a DOM object through jquery.   2.jQuery objects and Dom objects are converted to each other.   good writing style:var $input =$ ("input")the object that jquery gets is preceded by a variable of $. <1>jquery objects into DOM objects, two methods: [index] and get (index)A:var $cr =$ ("#cr")//jquery objectsvar cr= $cr [0]//dom ObjectB:var $cr =$ ("#cr")//jquery objectsvar cr= $cr. Get (0); Dom Object  <2>dom objects into jquery objectsvar Cr=document.getelementbyid ("Cr"); Dom Objectvar $cr =$ (CR);   3. Resolve conflicts with other librariesjquery.noconflict (). jquery uses $ as a shortcut to itself.   4. Advantages of using jquery<1> Concise wording<2> support CC1 to CCS3<3> Perfect processing mechanism  running the above code browser will be an error! But if you write it this way: $ (' #tt '). CSS ("Color", "red"); the browser will not error because there is no such element!   5.jQuery Selectorjquery Selector is the weight of jquery!  The jquery filter selector is similar to the pseudo-class selector in CSS.   <1> even and odd selectorseven: $ ("Tr:even")Odd: $ ("tr:odd")  <2>CSS3 pseudo class selector odd even
p:nth-child (Odd) {background:#ff0000;} P:nth-child (even) {background:#0000ff
<2> Form Type selector <3> Escape selector prevents errors   6.DOM Operation Classification (1:dom Core 2.html-dom 3.css-dom) 1.DOM CoreDom Core does not belong to JavaScript, any kind of DOM-enabledIt can be used by the programming language. Its purpose is not limited to the processing of web pages. can also be used toprocess any document written using markup LanguageFor example: XML。  2.html_domwhen scripting HTML files using JavaScript and DOM, there are many attributes that are specifically html--dom. Html_dom provides some more concise notation to describe the attributes of various HTML elements. such as:
Document.formselement.src
only for Web  3.css_dom
Css_dom is a CSS-specific operation. The main is to get and set various properties of the style object. by changing the various properties of the style object. Change different effects.  element.style.color= "Red"; 7. Traversing nodes1.children ()2.next ()3.prev ()4.siblings ()5.closest ()   8.jquey of CSS <1> can use opacity to set transparency, and jquery has handled compatibility issues. $ ("P"). CSS ("opacity", "0.5");  <2>$ ("P"). Height (100)//100 The default unit is PX, if you want to use a different unit, you must use the string  <3>offset () method
returns the offset from the relative window var offset=$ ("P"). offset (); var left=Offset.left; var top=offset.top;
  <4>position ()
// returns the offset relative to the most recent position style.  var position=$ ("P"). Position (); var left=Position.left; var top=position.top;
  <5>scrolltop () and scrollleft ()
// Returns the distance from the top of the scroll bar to the left of the distance.  var $p =$ ("P"); var top=$p. scrolltop (); var left= $p. scrollleft ();
// You can also set the scroll to the specified location:$ ("AB"). scrolltop (300);

  <6>pagex and Pagey, get the mouse position on the page
$ (document). MouseMove (function(e) {  $ ("span"). Text ("X:" + E.pagex + ", Y:" + E.pagey);}); 

Sharp Jquery--jquery and DOM object conversion, Dom three operations (reading note one)

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.