How jQuery Selectors can make your process easy with quick response

  • March 27, 2014
  • Ashish Shah
  • Web Design and Development
  • No Comments
Top-5-Reasons-for-Choosing-Joomla-for-your-Web-Designing

jQuery is a very strong JavaScript library generally used for DOM manipulations. As the name suggests ‘Query’ you can query(traverse) the DOM and do the manipulations. jQuery is a very powerful JavaScript platform that brings DOM manipulations handy with just few lines of code. Though its just a wrapper to plain JavaScript but, undoubtedly it enhances its powers and gives flexibility and that too with a small snippet of code. JQuery mainly plays around using ‘selectors’. Selectors can be looked upon as a ‘query’ i.e. based on the selector it queries(selects) elements from the DOM and returns as jQuery object. It should be noted that, when matched elements are more than one then what is returned by jQuery is array of objects. I have filtered out some of the common though important selectors that you may find useful.You can find a complete list of selectors on official site of jQuery. jQuery(“*”) Selects all the elemtns in DOM, returns array of jQuery objects. jQuery([name|=”value”]) Will select elements which has ‘name’ attribute and its value is either equal to or starts with ‘value’ followed by (-) jQuery([name*=”value”]) In this case jQuery will search for elements which has ‘name’ attribute and value of that attribute contains ‘value’ in it jQuery([name=”value”]) Will select elements which has ‘name’ attribute and its value is equal to ‘value’ jQuery(“.class”) Will select all the elements with ‘class’ class. jQuery(“ancestor descendant”) One of the most powerful and useful selectors amongst all. This selects elements considering the specified hierarchy for e.g : jQuery(‘div label span’); will find all the ‘span’ elements that are in the specified hierarchy i.e. all the span elements that have label as their immediate parent and that label has a div as its immediate parent. This selector generally helps conflict less DOM element selection. Here is a link for your reference: http://api.jquery.com/category/selectors/

About The Author

Avatar

Ashish Shah

Ashish Shah is the Founder and CEO of NCode Technologies, Inc. a leading Web & Mobile App Development Company based in India. He is the chief mentor and strategist with over 10+ years of experience in providing various IT solution to different industries. He also likes to share his view on different technology and marketing techniques via different blogs and articles.

Leave a Reply

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