views:

34

answers:

3

What is a safe and reliable way to select the link below? I am having trouble to ensure I include the "Select" text in the selector to ensure I do not select another link:

<span class="pickerWrapper">....<a href="...">Select</a></span>
+4  A: 

You will need to use the contains selector.

$(".pickerWrapper a:contains('Select')");
Mike
How do I get the last link that contains 'Select' though? Doesn't contain return a collection of elements?
TruMan1
This will return all links that contain the text "Select". If you want to always return one, you could use :first, :last, or other combinations of selectors.
Mike
A: 

jQuery(".pickerWrapper a:last") should work

sushil bharwani
How do I ensure that the last link contains 'Select'? Is there a way to include this in your selector?
TruMan1
A: 
$('.class a:contains("Select"):last')

http://jsfiddle.net/WwSNb/

Sam