如何使用jquery在div元素中的href链接中查找单词

时间:2014-10-02 09:18:48

标签: javascript jquery html loops switch-statement

有一个div元素,它总是包含一个href元素中的一个数组字。根据单词的含义,我需要将网页重定向到其他页面。我不确定我遗失了什么。

http://jsfiddle.net/5Legahgn/5/

 if ($('.container-fluid:contains("It looks something like this")').length > 0 || ($('.container-fluid:contains("Have you visited")').length > 0)) {
var uTest = ["Saggitarius", "Quentin", "Cinthia", "Maleria", "Pete", "Library", "wizard"];
var aTest = uTest.length;
var i = 0;
for (i; i < aTest; i++) {
    if ($('.container-fluid:contains("'+uTest[i]+'")').length > 0) {
        var mTest = uTest[i];
        if (mTest != null || undefined) {
            switch (mTest) {
                case "Saggitarius":
                    window.location.href = 'https://subeta.net/quests.php/saggitarius';
                    break;
                case "Quentin":
                    window.location.href = '...';
                    break;
                case "Cinthia":
                    window.location.href = '...';
                    break;
              case "Maleria":
                    window.location.href = '...';
                    break;
                case "Pete":
                    alert("Pete");
                    break;
              case "Library":
                    window.location.href = '...';
                    break;
              case "wizard":
                    window.location.href = '...';
                    break;
                case "Mori":
                    window.location.href = '...';
                    break;
            }
        } else {
            alert("done");
        }
    }
}

}

0 个答案:

没有答案