如果window hash匹配data-attr,则为addclass

时间:2016-01-04 03:34:14

标签: javascript jquery

我有以下内容,我认为它会起作用,但我似乎可以得到一个结果。

if (window.location.hash === '[data-toggle-box="' + window.location.hash + '"]') {
            $("[data-toggle-box='" + window.location.hash + "']").addClass('active');
            console.log('works');
        }

在验证data-attr中的值时,我是否遗漏了一些小问题?

0 个答案:

没有答案