1

i have those classes:

.slider
.sliderlogo

and i have those pieces of codes:

var sc=$(".slider img").size();
$(".slider #"+count).show("slide",{direction:'right'},500);
$(".slider #"+count).delay(5500).hide("slide",{direction:'left'},500);

what's the right way to add the other "slidelogo" class to the JS so it will run on the other class as well?

generaly its like:

(".slider #1,.sliderlogo #1")

bit its not working for the above code lines. thanks in advance.

1
  • 7
    ID must be unique in the entire document. Commented Nov 13, 2013 at 14:30

3 Answers 3

1

It looks like you might have issues with your markup, as IDs must be unique on the document and cannot begin with a number. If you must use the Ids, try building them as something like 'slider' + count and 'sliderLogo' + count. so that each is unique.

Sign up to request clarification or add additional context in comments.

2 Comments

yeah i forgot that i numbered 2 groups of images in the same id's. however,ID's can start with numbers, since HTML5 arrived.
@NetanelDadon Technically that is true, but as with all HTML5 features, you should be aware of them in case you have to support older browsers.
1

The ID should be unique in the entire document, so i recommend you to use classes instead, something like .item-1, .item-2 and then change the code to:

var sc=$(".slider img").size();
var selector = ".slider .item-" + count + ", .sliderlogo .item-" + count;
$(selector).show("slide",{direction:'right'},500);
$(selector).delay(5500).hide("slide",{direction:'left'},500);

Comments

1

As David says, the id must be unique, so try changing them to

.slider #slider1

and

.sliderlogo #sliderlogo1

etc.

then use:

(".slider #slider"+count+",.sliderlogo #sliderlogo"+count)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.