开发者

Using multiple jQuery selectors to filter

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜