Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to show div by value or id.
Although i don't want to use select dropdown.
Please see the working fiddle

JavaScript
$(function() {
    $('#colorselector').change(function(){
        $('.colors').hide();
        $('#' + $(this).val()).show();
    });
});


XML
<div>
  <ul id="colorselector">
    <li class="init">[SELECT]</li>
    <li value="red">Red</li>
    <li value="yellow">Yellow</li>
    <li value="blue">Blue</li>
  </ul>
  <div id="red" class="colors" style="display:none"> red... </div>
<div id="yellow" class="colors" style="display:none"> yellow.. </div>
<div id="blue" class="colors" style="display:none"> blue.. </div>

</div>
Posted

1 solution

Please check this fiddle... Changes done to your code...

js fiddle link
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900