• jQuery Selectors and Events

    In the topic jQuery Selectors and Events, To select and manipulate HTML element(s) dynamically then jQuery selectors are used. With jQuery Selectors we can search HTML elements with their different properties like, id, classes, types, attributes, value of attributes and many more. jQuery has their own custom selectors along with existing CSS Selectors.

    Basic Syntax:         $(selector).action()

    Where,

    • A $ sign define/access jQuery
    • A (selector) to “query (or find)” HTML elements
    • A jQuery action() t be performed on the elements(s)
    Syntax Description
    $(“*”) Selects all elements
    $(this) Selects the current HTML element
    $(“p.intro”) Selects all <p> elements with class=”intro”
    $(“p:first”) Selects the first <p> element
    $(“ul li:first”) Selects the first <li> element of the first <ul>
    $(“ul li:first-child”) Selects the first <li> element of every <ul>
    $(“[href]”) Selects all elements with an href attribute
    $(“a[target=’_blank’]”) Selects all <a> elements with a target attribute value equal to “_blank”
    $(“a[target!=’_blank’]”) Selects all <a> elements with a target attribute value NOT equal to “_blank”
    $(“:button”) Selects all <button> elements and <input> elements of type=”button”
    $(“tr:even”) Selects all even <tr> elements
    $(“tr:odd”) Selects all odd <tr> elements

    jQuery Event Methods

    In jQuery, Event Handlers are methods that are called when “something occurs” with HTML controls. The user often called term as “triggered/fired by an event” of controls.

    There are few jQuery Event Methods

    Event Method Description
    $(document).ready(function) Specifies a function to execute when the DOM is fully loaded
    $(selector).click(function) Binds/Triggers the click event
    $(selector).dblclick(function) Binds/Triggers the double click event
    $(selector).focus(function) Binds/Triggers the focus event
    $(selector).mouseover(function) Binds/Triggers the mouseover event
    Appreciate my work :Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPin on PinterestShare on RedditShare on StumbleUponShare on TumblrDigg thisShare on YummlyShare on VKFlattr the authorBuffer this page

Leave a Reply

Your email address will not be published. Required fields are marked *