Jump to content

help with code


CyberShot

Recommended Posts

I am using this code in my site and it works fine. But I have been trying to figure out how to use it in a unordered list instead of a select box. The reason is that I want to be able to change the look of the select box and you can't do that. I like this code because you can add new options without having to modify the jquery code to find those new values.

 

can you figure out how to make this work with an unordered list?

 

<script type="text/javascript">
$(document).ready(function(){
$('.box1').hide();
$('.box2').hide();
$('.box3').hide();
$(".thechoices").change(function(){
$("." + this.value).show().siblings().hide();
});

$(".thechoices").change();

});
</script>

</head>
<body>
<select class="thechoices">
<option value="box1">Box 1</option>
<option value="box2">Box 2</option>
<option value="box3">Box 3</option>
</select>

<!-- the DIVs -->
<div class="boxes">
<div class="box1"><p>Box 1 stuff...</p></div>
<div class="box2"><p>Box 2 stuff...</p></div>
<div class="box3"><p>Box 3 stuff...</p></div>
</div>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.