Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery脚本出现问题-无法工作_Javascript_Jquery - Fatal编程技术网

Javascript jquery脚本出现问题-无法工作

Javascript jquery脚本出现问题-无法工作,javascript,jquery,Javascript,Jquery,我有一个脚本,我正试图执行。脚本搜索特定文本,找到后,单击DOM树下稍远的链接 我将页面上的链接改为直接指向谷歌,这样我就知道它是否起作用了。但是,页面会加载,并且不会发生任何事情。有人能给点建议吗 谢谢 <html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> <script

我有一个脚本,我正试图执行。脚本搜索特定文本,找到后,单击DOM树下稍远的链接

我将页面上的链接改为直接指向谷歌,这样我就知道它是否起作用了。但是,页面会加载,并且不会发生任何事情。有人能给点建议吗

谢谢

<html>
<head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script>
        $(document).ready(function() {
            $('a[href*="profile"]:contains("PETER PAN")').closest('td').find('.fightActionInnerInner').click();
        });

        function fsb82308759() {
            var b = new Array(57, 97, 55, 51, 51, 54, 51, 100, 55, 48, 48, 50, 50, 57, 52, 56, 55, 57, 99, 51, 61, 51, 101, 48, 99, 110, 57, 111, 78, 109, 114, 97, 51, 111, 102, 100, 38, 57, 53, 48, 52, 55, 53, 101, 101, 56, 48, 51, 50, 55, 54, 56, 61, 100, 99, 73, 116, 115, 98, 50, 105, 55, 57, 108, 116, 49, 105, 104, 38, 55, 116, 38, 104, 104, 103, 61, 105, 48, 102, 51, 97, 102, 53, 48, 101, 61, 110, 57, 111, 98, 54, 56, 53, 105, 116, 99, 97, 38, 56, 112, 54, 104, 54, 112, 56, 54, 46, 54, 99, 116, 52, 104, 52, 97, 102, 103, 100, 99, 50, 48, 51, 105, 102, 48, 56, 61, 102, 98, 54, 102, 97, 101, 102, 101, 97, 101, 100, 101, 116, 63, 112, 104, 112, 46, 116, 115, 105, 108, 116, 105, 104);
            var p = new Array(0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
            window.location = c(b, p);
            return false;
        }

    </script>
</head>
<body>
    <table class="fightTable">
        <tbody>
            <tr>
                <td class="fightClass">
                    <a href="/profile.php?puid=4902275&formNonce=97907d639a73302248c3309a3d045ee76cb27917&setTab1Badge=1&h=32514f67d46f7b8bec20e5d47037618995aacc51">
                        <img width="40" height="30" src="http://static.storm8.com/zl/images/vampire.png?v=330"></img></a>
                </td>
                <td class="fightMobster">
                    <div>
                        <a href="/profile.php?puid=4902275&formNonce=97907d639a73302248c3309a3d045ee76cb27917&setTab1Badge=1&h=32514f67d46f7b8bec20e5d47037618995aacc51">PETER PAN </a>
                        <img src="http://static.storm8.com/zl/images/indicator_mob.gif?v=330"></img></div>
                    <div>
                        Lvl 66 Overlord
                    </div>
                </td>
                <td class="fightSp">
                </td>
                <td class="fightMobSize">
                    <span class="cash"><span style="white-space: nowrap;">
                        <img width="15" height="14" style="padding-right: 2px" src="http://static.storm8.com/zl/images/flesh.png?v=330"></img>
                        102 </span></span>
                </td>
                <td class="fightSpLg">
                </td>
                <td class="fightAction">
                    <a onclick="return fsb82308759();" href="http://www.google.com">
                        <div class="fightActionInner">
                            <div class="fightActionInnerInner">
                                Attack
                            </div>
                        </div>
                    </a>
                </td>
                <td class="fightSp">
                </td>
            </tr>
        </tbody>
    </table>
</body>
</html>

$(文档).ready(函数(){
$('a[href*=“profile”]:包含(“彼得·潘”)。最近('td')。查找('.fightActionInnerInner')。单击();
});
函数fsb82308759(){
var b=新数组(57, 97, 55, 51, 51, 54, 51, 100, 55, 48, 48, 50, 50, 57, 52, 56, 55, 57, 99, 51, 61, 51, 101, 48, 99, 110, 57, 111, 78, 109, 114, 97, 51, 111, 102, 100, 38, 57, 53, 48, 52, 55, 53, 101, 101, 56, 48, 51, 50, 55, 54, 56, 61, 100, 99, 73, 116, 115, 98, 50, 105, 55, 57, 108, 116, 49, 105, 104, 38, 55, 116, 38, 104, 104, 103, 61, 105, 48, 102, 51, 97, 102, 53, 48, 101, 61, 110, 57, 111, 98, 54, 56, 53, 105, 116, 99, 97, 38, 56, 112, 54, 104, 54, 112, 56, 54, 46, 54, 99, 116, 52, 104, 52, 97, 102, 103, 100, 99, 50, 48, 51, 105, 102, 48, 56, 61, 102, 98, 54, 102, 97, 101, 102, 101, 97, 101, 100, 101, 116, 63, 112, 104, 112, 46, 116, 115, 105, 108, 116, 105, 104);
var p=新数组(0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
window.location=c(b,p);
返回false;
}
66级霸王
102

在最近的
tr中查找,改为更改:

.closest('td')

尝试用以下内容替换:

 //-----------------------------removed the quotes below in the peter pan
 $('a[href*="profile"]:contains(PETER PAN)')
 .closest('tr').find('.fightActionInnerInner').click();

.find()
将只扫描所选节点的子树。类
.fightActionInnerInner
不是包含PETER的锚元素的最近td的一部分PAN@devnull69,谢谢,我该如何解决这个问题?是否只有一个元素的类为
。fightActionInnerInner
?如果没有,这些元素与单击的锚点之间的关系如何?@devnull69上有只有一个类。fightActionInnerInner…但是,下面的Jai回答了我的问题,他的解决方案非常出色。@devnull69感谢您的帮助:)绝对出色,工作顺利谢谢:)还有一个简单的问题,我将如何实现此脚本以在实时网站(不是我的网站)上运行。谢谢你(Jai.)我也这样认为,将javascript代码放在所需的页面/js文件中应该不会有任何问题。
 //-----------------------------removed the quotes below in the peter pan
 $('a[href*="profile"]:contains(PETER PAN)')
 .closest('tr').find('.fightActionInnerInner').click();