JavaScript gets the ID element

Source: Internet
Author: User

function $ (ID) {

return document.getElementById (ID);

}

The document.getElementById (ID) is the element that obtains the ID.

The equivalent of defining a method that uses $ ("ID0") to get the control with ID id0.

And this definition is only used in projects that don't have jquery, and when you use $ and then jquery, all your code about jquery is useless, so here we

Do not be fooled by his $, this is just a variable name, casually take, you use x also line, so use is X ("Id0").

Change the above code to the following code, and you will change the $ x to

function x (ID) {

return document.getElementById (ID);

}

$ is the operator inside jquery

JavaScript gets the ID element

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.