jquery Objects and Dom objects

Source: Internet
Author: User

jquery objects are not the same as DOM objects

Example:
<id= "OOC"></p>

Normal processing, handled by standard javascript:
<script>var p = document.getElementById (' Ooc ');  // get the element with ID OOC in the P tag, add a word to the text node, make the color red p.innerhtml = ' Learn jquery knowledge '= ' red '; </script>



The processing of jquery:
<script>var $p = $ (' #ooc '); $p. html (' Learning jquery Knowledge '). CSS (' Color ', ' red '); </script>
 

How do I turn a jquery object into a DOM object ?



html code
< Div > Element One </div><Div> element two </  div><Div> elements three </Div  >

JavaScript code
<script>var//jquery object var// Convert to DOM object //  Manipulating the properties of Dom objects </script>


The Get () method that comes with jquery
<script>var//jquery object var// via Get method, convert to DOM object //  manipulating the properties of Dom objects </script>

Calling jquery after a normal DOM object is processed into a jquery object through the $ (DOM) method
JavaScript code <script>var//DOM Object var//jquery Object  var// Find First DIV element // set color for first element </script>

jquery Objects and Dom objects

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.