3gwebtrain
3gwebtrain

Reputation: 15303

How to make jQuery condition?

I am doing a slide show, for that i am checking the slide number. there two options show and hide, for that i wrote this condition. is this correct ? not it's through the error.

 var onSlide_ag = (onSlide_ag == 1) ? $('id="a_prev"').hide() : $('id="a_prev"').show();

any one correct it? or let me know the mistake with i did..?

This is actually need to use in the if conditions, but i used the short way to make this out put.

thanks in advance!

Upvotes: 0

Views: 233

Answers (3)

genesis
genesis

Reputation: 50976

try this one

 var onSlide_ag = (onSlide_ag == 1) ? $('#a_prev').hide() : $('#a_prev').show();

Upvotes: 3

Giann
Giann

Reputation: 3192

To select an element with a given id you have to use #:

var onSlide_ag = (onSlide_ag == 1) ? $('#a_prev').hide() : $('#a_prev').show();

Upvotes: 2

Sjoerd
Sjoerd

Reputation: 75609

Your selector is incorrect. Use $('#a_prev') instead of $('id="a_prev"').

The jQuery page has a list of all selectors, where the ID and class selectors are most used.

Upvotes: 2

Related Questions