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
https://forums.phpfreaks.com/topic/185377-help-with-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.