I'm currently facing a problem with a jQuery function. The task of the function is to detect if the URL has a specific string in it, and then do a specific task. This is the code:
var url = window.location.href;
if (url.search('slick0') > -1) {
$('.accordion #slider0 dt').addClass('open').removeClass('closed');
$($slider).slick('setPosition');
}
The part "slider0" and "slick0" should be any integer. So the function should search for 'slickN', where N is the integer, and then do the actions on '.accordion #sliderN dt', as in the function above.
I've tried the following code, but it doesn't work at all, and I haven't had any luck trying or even finding different ways to a solution, for which me being not a native speaker may be the cause, but I just can't seem to find the right direction.
This is my alternative which does not work at all:
var url = window.location.href;
var sliderNumber = $.isNumeric;
if (url.search('slick'+sliderNumber) > -1) {
$('.accordion #slider'+sliderNumber 'dt').addClass('open').removeClass('closed');
$($slider).slick('setPosition');
}
Can anyone help me or point me into the right direction? Any help is appreciated! Thanks!
Aucun commentaire:
Enregistrer un commentaire