How to use jQuery selectors ?

498 views October 5, 2016 November 15, 2016 admin 2

jQuery selectors in wpsolr are used to associate live suggestions and geolocation to your theme’s search box(es).

When the wpsolr javascript code needs to identify your search box(es), to attach specific events, it does so by using jQuery selectors.

What is jQuery ?

jQuery is a javascript library, widely used to simplify the manipulation of the elements of a HTML page, the Document Object Model (DOM).

What are jQuery selectors ?

They are a way for a javascript code to identify a HTML element, or several HTML elements. It can be an id, a class, a name, a descendant, an ascendant. There are many ways to identify HTML elements in the Document Object Model (DOM).

See examples from w3schools

How do I find my selectors ?

In your browser, hover the search box for which you want to retrieve a selector from, then right click to open the browser inspector. It will show you the HTML code of your search box.

If the HTML code contains

id="myId"

then your jQuery selector could be

#myId

 

If the HTML code contains

class="myclass"

then your jQuery selector could be

.myclass

 

 

Was this helpful?

Leave A Comment
*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.