Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get element by title jQuery

I have searched but cannot find the jQuery selector that gets an element by a title. So I would be trying to get a handle on the dropdown with title =='cars'

Eg:

<select title='cars'>   <option value="volvo">Volvo</option>   <option value="saab">Saab</option>   <option value="mercedes">Mercedes</option>   <option value="audi">Audi</option> </select> 

Thanks alot,

like image 882
van Avatar asked Jun 20 '10 18:06

van


People also ask

How do you select an element by title?

We can find and click elements by title in Selenium webdriver. An element can be identified with a title attribute with xpath or css selector. With the xpath, the expression should be //tagname[@title='value']. In css, the expression should be tagname[title='value'].

How can I select an element by name with jQuery?

How to select an element by name with jQuery? The JavaScript getElementsByName() method can be used to select the required element and this can be passed to a jQuery function to use it further as a jQuery object.

What is ATTR jQuery?

jQuery attr() Method The attr() method sets or returns attributes and values of the selected elements. When this method is used to return the attribute value, it returns the value of the FIRST matched element.

How Get contains in jQuery?

jQuery :contains() SelectorThe :contains() selector selects elements containing the specified string. The string can be contained directly in the element as text, or in a child element. This is mostly used together with another selector to select the elements containing the text in a group (like in the example above).


1 Answers

Use the attribute-equals selector, like this:

$("select[title='cars']") 

There are other attribute selectors available as well if the need arises :)

like image 129
Nick Craver Avatar answered Sep 26 '22 14:09

Nick Craver