目标 SELECT 选项 JQuery

Target SELECT option JQuery

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

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);

 });

如何实现?我在网站上使用其他解决方案没有成功。

你可以试试

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