0

I have this jQuery code

var  c = ".c10";
$('[data-option-value="c"]a').trigger("click")

This code performs the click event. c10 is an id from one specific element. This code works fine without using variable : $('[data-option-value=".c10"]a').trigger("click")

As you see in the first code I used variable instead of using it directly but I didn't get any answer. Did I miss something?

Hope someone could help!

3
  • You need to concatenate the variable to the string. See the duplicates I marked for more information Commented Oct 4, 2017 at 10:39
  • Try this: $('[data-option-value='+c+']a').trigger("click"); Commented Oct 4, 2017 at 10:51
  • thanks @RoryMcCrossan Commented Mar 7, 2018 at 13:52

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.