JQuery Syntax (i)

Source: Internet
Author: User
Tags button type

With JQuery, you can select (query) HTML elements and perform actions on them.

jQuery Syntax Instance $ ( This). Hide () demonstrates the jQuery hide () function, which hides the current HTML element. $("#test"). Hide () demonstrates the jQuery hide () function, hiding the ID="Test"the element. $("P"). Hide () demonstrates the jQuery hide () function, hiding all<p>element. $(". Test"). Hide () demonstrates the jQuery hide () function, hiding allclass="Test"The element.
JQuery syntax

The jQuery syntax is for the selection of HTML elements, and you can perform certain operations on elements.

The underlying syntax is: $ (selector). Action ()

    • Dollar sign definition JQuery
    • Selector (selector) "Query" and "find" HTML elements
    • JQuery Action () performs an operation on an element
Example

$ (this). Hide ()-hides the current element

$ ("P"). Hide ()-Hides all paragraphs

$ (". Test"). Hide ()-hides all elements of class= "test"

$ ("#test"). Hide ()-hides all elements of the id= "test"

Tip: The syntax used by JQuery is a combination of XPath and CSS selector syntax. In the next chapters of this tutorial, you will learn more about selectors syntax.

Document-Ready functions you may have noticed that all of the jQuery functions in our instance are in one of the document readiness functions: $ (document). Ready (function () {---jQuery functions Go here----}); This is to prevent the document from running JQuery code before it is fully loaded (ready). If you run the function before the document is fully loaded, the operation may fail. Here are two specific examples: trying to hide a nonexistent element to get the size of an image that is not fully loaded

Sample code

<! DOCTYPE html>"/jquery/jquery-1.11.1.min.js" ></script><script>$ (document). Ready (function () {  $ ("P" ). Click (function () {    $ (this). Hide ();  });}); </script>
"Text/javascript"Src="Jquery.js"></script><script type="Text/javascript">$ (document). Ready (function () {$ ("Button"). Click (function () {$ ("P"). Hide ();} );</script> isA heading isA paragraph.</p><p>this isAnother Paragraph.</p><button type="Button">click me</button></body>

JQuery Syntax (i)

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.