目标SELECT选项JQuery

时间:2016-01-19 11:26:38

标签: jquery select html-select

我试图通过JQuery在option下拉列表中定位select

HTML:

<select id="category-select" name="category">
    <option class="all" value="all">All</option>
    <option class="env-tech" value="environmental-technologies">Environmental Technologies</option>
    <option class="digital-media" value="digital-media">Digital Media</option>
    <option class="serv-consumer" value="services-consumer">Services/Consumer</option>
    <option class="bio" value="bio-technology">Medical/Biotechnolgy</option>
</select>

JQuery

('#category-select option[value="environmental-technologies"]').click(function() {

    $('.portfolio-area').show().filter(':not(.environmental-technologies)').fadeOut(200);

 });

我如何实现这一目标?我在网站上没有其他解决方案的成功。

1 个答案:

答案 0 :(得分:2)

您可以尝试

$(document).on("change","#category-select", function(){
    if($(this).val()=='environmental-technologies')
    {
        alert(1); // Your code $('.portfolio-area').show()....
    }
});