Javascript Jquery在DropDownList上激活/选择项已更改
我有一些JQuery代码可以过滤掉页面上的链接列表。目前,当单击带有盲href的链接时,会触发筛选。链接的id用于确定页面上哪些内容仍然可见。例如:Javascript Jquery在DropDownList上激活/选择项已更改,javascript,jquery,html,Javascript,Jquery,Html,我有一些JQuery代码可以过滤掉页面上的链接列表。目前,当单击带有盲href的链接时,会触发筛选。链接的id用于确定页面上哪些内容仍然可见。例如: <script type="text/javascript"> $(document).ready(function () { //when a link in the filters div is clicked... $('#filters a').click(function (e) { //p
<script type="text/javascript">
$(document).ready(function () {
//when a link in the filters div is clicked...
$('#filters a').click(function (e) {
//prevent the default behaviour of the link
e.preventDefault();
//get the id of the clicked link(which is equal to classes of our content
var filter = $(this).attr('id');
//show all the list items(this is needed to get the hidden ones shown)
$('#content ul li').show();
/*using the :not attribute and the filter class in it we are selecting
only the list items that don't have that class and hide them '*/
$('#content ul li:not(.' + filter + ')').hide();
});
});
$(文档).ready(函数(){
//单击“过滤器”分区中的链接时。。。
$(“#过滤器a”)。单击(函数(e){
//防止链接的默认行为
e、 预防默认值();
//获取单击链接的id(它等于我们内容的类)
var filter=$(this.attr('id');
//显示所有列表项(这是获取显示的隐藏项所必需的)
$(#content ul li').show();
/*使用:not属性和我们正在选择的过滤器类
仅列出不具有该类的项并隐藏它们'*/
$(“#内容ul li:not(.+filter+)”).hide();
});
});
我需要对此进行更改,以便在DropDownList/SELECT中更改选项时激活JQuery。但是,我无法完全理解如何更改此JScript以检测DDL中的选择,而不是超链接
任何帮助都将不胜感激
谢谢。使用change()事件
这将在每次进行下拉选择时触发。使用change()事件
这将在每次选择下拉菜单时触发。太好了。谢谢,我现在试一试。太好了。谢谢,我现在试一试。
$("#idOfDropDown").change(function() {
//code here
var filter = this.value //gets the value of the selected dropdown item.
});