In a form there is a section that shows groups of 4 weeks in each div. See the code below
<div class="form-check" data-weeknr="1,2,3,4"></div>
<div class="form-check" data-weeknr="5,6,7,8"></div>
<div class="form-check" data-weeknr="9,10,11,12"></div>
<div class="form-check" data-weeknr="13,14,15,16"></div>
<div class="form-check" data-weeknr="17,18,19,20"></div>
... This continues until it reaches
<div class="form-check" data-weeknr="49,50,51,52"></div>
I have a code that grabs the current week by the variable weekno so console.log(weekno); returns today: 3
I want to add a class current to the .form-check that has weekno in it's data-attribute data-weeknr.
So I tried to use the attribute contains selector instructions, but I need it to go deeper than these instructions allow.
$links = $(".formplate .form-check[data-weeknr*='3']");
console.log($links.length);
Because the above jQuery code will return in the console the number 7 due to the fact it now grabs every .form-check that has a 3 init. So it grabs not only 3 but also 13,23,[30,31,32],[33,34,35,36],[37,38,39],43 making the total of 7 groups.
So how can I change this line to do 2 things:
$links = $(".formplate .form-check[data-weeknr*='3']");
How to incorporate the variable weekno, how can I properly escape so that the var is allowed?
And how can I make it select only the number 3?