.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> JQuery >> Post New Question Subscribe to Interview Questions

What is jQuery Selectors

Posted By :Ashutosh Jha     Posted Date :June 30, 2014    Points :40   Category :JQuery 
jQuery Selectors are used to select one or a group of HTML elements from your web page.
. jQuery support all the CSS selectors as well as many additional custom selectors.
. jQuery selectors always start with dollar sign and parentheses: $()
. There are three building blocks to select the elements in a web document.

Select elements by tag name
Select elements by ID
Select elements by class

that have an odd index value.

$("li:first"): Selects the first
  • element.

    $("li:last"): Selects the last
  • element.

    $("li:visible"): Selects all elements matched by
  • that are visible.

    $("li:hidden"): Selects all elements matched by
  • that are hidden.

    $(":radio"): Selects all radio buttons in the form.

    $(":checked"): Selects all checked boxex in the form.

    $(":input"): Selects only form elements (input, select, textarea, button).

    $(":text"): Selects only text elements (input[type=text]).

    $("li:eq(2)"): Selects the third
  • element

    $("li:eq(4)"): Selects the fifth
  • element

    $("li:lt(2)"): Selects all elements matched by
  • element before the third one; in other words, the first two
  • elements.

    $("p:lt(3)"): selects all elements matched by

    elements before the fourth one; in other words the first three

    elements.

    $("li:gt(1)"): Selects all elements matched by

  • after the second one.

    $("p:gt(2)"): Selects all elements matched by

    after the third one.

    $("div/p"): Selects all elements matched by

    that are children of an element matched by

    .

    $("div//code"): Selects all elements matched by that are descendants of an element matched by
  • that are the first child of their parent.

    $("li:last-child"): Selects all elements matched by
  • that are the last child of their parent.

    $(":parent"): Selects all elements that are the parent of another element, including text.

    $("li:contains(second)"): Selects all elements matched by
  • that contain the text second.

    You can use all the above selectors with any HTML/XML element in generic way. For example if selector $("li:first") works for
  • element then $("p:first") would also work for

    element. (More...)

    What is JQuery?

      
    JQuery is Java Script library or Java Script Framework which helps in how to traverse HTML documents, do some cool animations, and add Ajax interaction to any web page. It mainly helps programmer to reduce lines of code as huge code written in Java Script, can be done easily with JQuery in few lines. (More...)

    What does dollar Sign ($) means in JQuery?

      
    Dollar Sign is nothing but it's an alias for JQuery. Take a look at below jQuery code

    $(document).ready(function(){

    });


    Over here $ sign can be replaced with "jQuery " keyword.

    jQuery(document).ready(function(){

    }); (More...)

    How is body onload() function is different from document.ready() function used in jQuery?

      
    Document.ready() function is different from body onload() function because off 2 reasons.

    1. We can have more than one document.ready() function in a page where we can have only one onload function.
    2. Document.ready() function is called as soon as DOM is loaded where body.onload() function is called when everything gets loaded on the page that includes DOM, images and all associated resources of the page. (More...)

    What are the steps you need to follow to use jQuery in ASP.Net project?

      
    It's really simple. One just need to add reference of javascript file(.js). Go to Jquery.com and download the latest version of jQuery. When download is completed, there is a "jQuery-1.3.2.js" in the folder. Include this file




    and you good to go now for JQuery.

    Note : 1.3.2 denotes the library version.. It can be vary depending upon the version of Jquery you download. (More...)

    Name some of the methods of JQuery used to provide effects?

      
    1. Show()
    2. Hide()
    3. Toggle()
    4. FadeIn()
    5. FadeOut() (More...)

    What is the basic used of jQuery() function

      
    ->Establish code to be executed when the DOM is ready for manipulation.
    ->Help as a namespace for global utility functions.
    ->Create DOM elements from HTML markup.
    ->Select and wrap DOM elements to operate upon (More...)

    What does hash and dot sign means in JQuery?

      
    both hash and dot used to identify the control available in the page.

    hash # is used to identify the control by control id.

    Dot . is used to get the control by its class name.

    for eg

    To use this control in JQuery we should use $('.dvclass')

    To use this control in JQuery we should use $('#dvclass') (More...)

    What is jQuery?

      
    jQuery is fast, lightweight and feature-rich client side JavaScript Library/Framework which helps in to traverse HTML DOM, make animations, add Ajax interaction, manipulate the page content, change the style and provide cool UI effect. It is one of the most popular client side library and as per a survey it runs on every second website. (More...)

    Why do we use jQuery?

      
    JQuery is used due to following advantages:-

    Easy to use and learn.
    Easily expandable.
    Cross-browser support (IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+)
    Easy to use for DOM manipulation and traversal.
    Large pool of built in methods.
    AJAX Capabilities.
    Methods for changing or applying CSS, creating animations.
    Event detection and handling.
    Tons of plug-ins for all kind of needs. (More...)

    Difference between JavaScript and jQuery?

      
    JavaScript is a language While jQuery is a library built in the JavaScript language that helps to use the JavaScript language. (More...)

  • You can also find related Interview Question to What is jQuery Selectors  below: 

    There are 3 types of selectors in Jquery?

      
    1. CSS Selector
    2. XPath Selector
    3. Custom Selector (More...)

    which are basic selectors in jQuery (cross browser)?

      
    ->Element ID's
    ->CSS class name
    ->Tag name
    ->last but not the least DOM hierarchy. (More...)

    What are selectors in jQuery and how many types of selectors are there?

      
    To work with an element on the web page, first we need to find them.

    To find the html element in jQuery we use selectors. There are many types of selectors but basic selectors are:

    Name: Selects all elements which match with the given element Name.

    #ID: Selects a single element which matches with the given ID

    .Class: Selects all elements which match with the given Class.

    Universal (*): Selects all elements available in a DOM.

    Multiple Elements E, F, G: Selects the combined results of all the specified selectors E, F or G.

    Attribute Selector: Select elements based on its attribute value.
    (More...)

    Explain different type of useful selectors in jQuery.

      
    Below is the list of different types of useful selectors in jQuery

    $('*'): This selector selects all elements in the document.

    $("p > *"): This selector selects all elements that are children of a paragraph element.

    $("#specialID"): This selector function gets the element with id="specialID".

    $(".specialClass"): This selector gets all the elements that have the class of specialClass.

    $("li:not(.myclass)"): Selects all elements matched by
  • that do not have class="myclass".

    $("a#specialID.specialClass"): This selector matches links with an id of specialID and a class of specialClass.

    $("p a.specialClass"): This selector matches links with a class of specialClass declared within

    elements.

    $("ul li:first"): This selector gets only the first

  • element of the
  • Quick Links For Interview Questions Categories:
    ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
    Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
    Biztalk Patten/Practices .IIS WCF WPF WWF
    Networking Aptitude Others   All      

    Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

     
    Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

    So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


    Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend