TheRealPapa
TheRealPapa

Reputation: 4539

jQuery target link with specific href on click

This I should know but it has eluded me. I have the following HTML generated by AVADA shortcode for tabs:

<a href="#tab34830639">Customer Address</a>

I want to do something like below but I am stuck.

jQuery("a:href='#tab34830639'").click(function(){

Upvotes: 1

Views: 5074

Answers (3)

Sudharsan S
Sudharsan S

Reputation: 15393

Use attribute selector like this

jQuery("a[href='#tab34830639']").click(function(){

Note : Attribute equal selector - Selects elements that have the specified attribute with a value exactly equal to a certain value.

Upvotes: 1

Razvan B.
Razvan B.

Reputation: 6771

$('a[href="#tab34830639"]').click(function() {

Available attributes:

= is exactly equal
!= is not equal
^= it starts with
$= it ends with
*= it contains
~= it contains word
|= it starts with prefix (i.e., |= "prefix" matches "prefix-...")

Attributes Documentation Here

And here is a working demo

Upvotes: 3

Rajaprabhu Aravindasamy
Rajaprabhu Aravindasamy

Reputation: 67187

Try to use attribute equals selector,

jQuery("a[href='#tab34830639']").click(function(){

This "a:href='#tab34830639'" is an invalid jquery selector.

Upvotes: 3

Related Questions