我正在尝试使用gt()
jQuery 集的过滤器。我的愿望是清除所有索引高于触发更改事件的元素的选定元素。我确定这与无法gt()
将变量作为整数接受有关thisIndex
,并且似乎找不到这样做的语法。
$(document).ready(function () {
$(".slct").change(function() { // sensitize all slct elements
thisIndex = $(".slct").index(this);
selGT1 = $(".slct:gt(1)"); // TEST: this correctly selects the elements greater than 1
selectsGT = $(".slct:gt(thisIndex)"); // "I WANT thisIndex TO ACT LIKE A INTEGER"
$(selectsGT).val(""); // clear elements w/ a index greater than "this"
});
});