在jquery中编写的这个语句会导致IE7 / 8上的语法错误?

时间:2012-05-12 02:35:20

标签: jquery internet-explorer syntax

我现在正在编写javascript代码,其中一个声明是:

if ($(this).is(":select")) {
    if ($(this).find("option").filter(":selected").length > 0) {
        var txt__ = $(this).find("option:selected:eq(0)").val();
        if ($.trim(txt__) != '') {
            flag_ = true;
        }
    }
}

在Chrome Firefox和IE9上,没关系。但就7月8日而言,它一直告诉我'语法错误',有些人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

问题出在第一行:

if ($(this).is(":select")) {

编辑:修正了基于OP评论的回复

我相信

if ($(this).tagName.toLowerCase() == "select") {

if ($(this).is(":input[type=select]")) {

应该这样做。