Address multiple jQuery selectors with one jQuery onHandler extension

pafe
New Member
pafe

Hi,

I want to track clicks on a specific button that can be found on several pages. The corresponding jQuery selector is something like:

button.btn.....##

At the end of the string there is a number ## which differs across pages. 

Can I use the jQuery onHandler extension and use a wildcard in the jQuery selector (something like button.btn....^) to track the clicks?

Thank you!

 

3 REPLIES 3

Address multiple jQuery selectors with one jQuery onHandler extension

Tealium Employee

HI @pafe 

You can use CSS selectors to filter attributes, as described here: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors

In your case, let us take the example class assigned to the button "button btn_12"

You could try using something like this which checks if it has the class "button" and has a class containing "btn_"

".button[class*='btn_']"

Hope that helps!

 

Highlighted

Address multiple jQuery selectors with one jQuery onHandler extension

pafe
New Member
pafe

Hi @rebman,

Thank you very much for your help! I'll try it.

Kind regards, 

 

 

Address multiple jQuery selectors with one jQuery onHandler extension

pafe
New Member
pafe

I could solve the problem with the following jQuery selector:

button[class*='btn_']

Thank you!