jquery selectors

Total Post:2

Points:14
 501  View(s)
Ratings:
Rate this:

Why id & elements are faster? &

why class selectors are slow?

  1. Post:140

    Points:984
    Re: jquery selectors

    jQuery selectors:

    Demonstrate the different selectors in jQuery like elements, class, attribute etc.

    Ex. 

    $("[href]")   // elements with href attribute
    
    $(".mindstick")   // elements with class="mindstick"
    $("#myname")   // elements with id="myname"
    $("[title^='prakash']")   // elements with attribute which start with "prakash".

    Id and elements are faster than class selector because id will be unique and it's only one time  matched data with DOM's database than stoped , but when you uses class it's called many times from DB and  it's performance will get slow.

    Happy Coding :)

      Modified On Jun-06-2018 11:17:52 PM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!