开发者

Using multiple jQuery selectors to filter

开发者 https://www.devze.com 2023-01-12 02:03 出处:网络
I am trying to add the jQueryUI datepicker on a certain group of datefields, but exclude fields whose id ends in -0

I am trying to add the jQueryUI datepicker on a certain group of datefields, but exclude fields whose id ends in -0

Here is my code:

$(function() {
            $("input[id^='TOEFLtestDate-']").not([id$='-0']).datepicker({
                onClose: function(dateText, inst){
                    GenericDateUpdate(this.id, dateText,1);
                }
            });
        });

This code selects the correct pool o开发者_运维技巧f inputs:

$(function() {
            $("input[id^='TOEFLtestDate-']").datepicker({
                onClose: function(dateText, inst){
                    GenericDateUpdate(this.id, dateText,1);
                }
            });
        });

I just can't seem to get the filtering right to filter out the ids that end in -0.

Thanks for any help.


You just need quotes in your first attempt, like this:

$("input[id^='TOEFLtestDate-']").not("[id$='-0']")

Or a bit cleaner, use the :not() selector, like this:

 $("input[id^='TOEFLtestDate-']:not([id$='-0'])")
0

精彩评论

暂无评论...
验证码 换一张
取 消