show/hide div based on select option jquery

后端 未结 4 1556
说谎
说谎 2020-11-27 13:08

Here is my code. Why it doesn\'t work?



        
4条回答
  •  感动是毒
    2020-11-27 13:52

    You are missing a :selected on the selector for show() - see the jQuery documentation for an example of how to use this.

    In your case it will probably look something like this:

    $('#'+$('#colorselector option:selected').val()).show();
    

提交回复
热议问题