0

我正在为我的键盘控制编写我的 jquery 代码。我需要一些有关 if 语句的帮助,我仍在尝试找出如何检查当前divwidth 大小为 250 的列值 2,同时检查元素 id '.row2' 和类 'span0hr'在做某事之前,列值 2 的大小为 250。

我试过这个:

if (current_row == 2 && currentdivwidth[0] == 250) {
    alert("passed");
    if (current_row == 2 && ($('.span0hr').hasClass('row2'))) {
        alert("fix this 1");
    } else if (current_row == 2 && ($('.row2').hasClass('span1hrfor30mins'))) {
        alert("fix this 2");
    }
}   

当列值为 2 且大小为 250 时我可以通过,但是当列值为 2 且大小为 250 时我不能通过同时检查元素 id '.row2' 和类'span0hr '。

当列值为 2 且大小为 250 时,您知道如何同时检查元素 id '.row2' 和类 'span0hr' 吗?

前几天我已经这样做了,但是由于被覆盖,我失去了工作。

4

1 回答 1

0

ID 选择器以# 开头。这 。用于在选择器上的类名之前。

IE。:

if ($("#row2").hasClass("theClassYouWant"))
    // do something

在这里试试:

http://jsfiddle.net/ptvtD/

于 2013-07-12T16:18:34.153 回答