0

I'm looking to make something which will have 100s of if statements I'm sure this isn't the best way but it's the way I know how to do it and I'm sure it will work. I want the user to be presented with two images when they click one it takes them to another set of images etc..

I'm not 100% sure how to do it using mouse click, would it be something along these lines

     if($('IMAGE ID').click())
     {
        page2a.html
     }
     else
     {
        page2b.html
     }

thanks!

So I would like some guidance on how to create an if statement, using images and mouse clicks. I know how to make one using the outcome of math for example;

if (5 > 10) etc..

But I have never used media, images before how do I add those to an if statement my attempt is posted above is this correct?

3
  • Can you please explain your exact issue? That can help others suggest you better options. Commented Mar 4, 2013 at 11:14
  • Sure 1 second I will post below my bad Commented Mar 4, 2013 at 11:15
  • I guess you mistake if click with on click Commented Mar 4, 2013 at 11:17

1 Answer 1

1

You can embed the image tag inside a anchor tag itself for solving this.

<a href="page2a.html"><img/><a>
<a href="page2b.html"><img/></a>

IF you want to dynamically load pages using query use like: EDIT: You can set the IMAGE_ID same as page2a or page2b

$('img').click(function() {
   var id= $(this).attr('id');
   window.location = id+'.html';
})
Sign up to request clarification or add additional context in comments.

3 Comments

Hi, I was thinking the same, but If I have for example, something like this - option 1a - Option 1b Option 2a - option 2b option 2c - option 2d I would have over 100 different pages, with every combination thats the only problem with that.
Please check the edited code above. You can try having IMaGE_ID and page names same so that you can avoid lot of if conditions
Ahh thanks this is what im looking for! whats the process called above?

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.