jQuery在括号编辑器上不起作用 [英] jQuery won't work on brackets editor

查看:71
本文介绍了jQuery在括号编辑器上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,嗨.我已经尝试了所有我知道和不知道的东西,而我根本无法使其工作.是的,我的html框架中有一个脚本标签.

So, hi. I've tried everything I know and don't know, and I simply can't make it work. Yes, I have a script tag in my html skeleton.

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

我也尝试下载它,然后将其作为脚本标签添加到我的html骨架中.什么都行不通.我在另一个file.js中输入了javascript/jquery,显然也链接到了我的html.

I also tried downloading it and then adding to my html skeleton as a script tag. Nothing works. I am typing my javascript/jquery in another file.js, which is obviously also linked to my html.

我正在使用Brackets编辑器.我在网络上找不到任何东西...而且我很确定问题是由于某种原因,jQuery目录未链接到我的其他.js文件,因为当我直接在内部键入javascript时我的html文件,它可以正常工作.

I'm using the Brackets editor. I couldn't find anything on the web... and I'm pretty sure that the problem is that for some reason, the jQuery directory is not linked to my other .js files, because when I type my javascript direct to a inside my html file, it works.

对于使用Brackets编辑器的每个人,我该怎么办? :(

For everyone using the Brackets editor, what do I have to do? :(

完整的html代码:

    <!DOCTYPE html>
<html>
    <head>
        <title>One Piece Website</title>
        <meta charset="utf-8" />
        <link rel="stylesheet" type="text/css" href="stylesheet.css">
        <script src="jquery.js" type="text/javascript"></script>
        <script src="javascript.js" type="text/javascript"></script>
    </head>
    <body>
        <div id="banner"></div>
        <div id="wrapper">
            <header>
                <div id="logo"></div>
                <div id="navbar"></div>
                <div id="slider">
                    <img src="imgs/slider-arrow.png" id="leftarrow" />
                    <h1>Novidades</h1>
                    <h2>Mantenha-se sempre informado.</h2>
                    <h3>
                        <a href="">SIT ELIT PELLENTESQUE</a>
                    </h3>
                    <p>
                        Ipsum et praesent elit accumsan pellentesque elit varius elit tellus tellus curabitur. Varius sollicitudin tortor velit faucibus varius vestibulum in praesent sit accumsan at mauris lacinia diam sollicitudin iaculis. In ad adipiscing adipiscing adipiscing nulla consectetur ac amet.
                    </p>
                </div>
            </header>
        </div>
        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    </body>
</html>

JS:

$(document).ready(function() {
$('#slider').mouseenter(function() {
    $('#leftarrow').css('display', 'block');
    $('#rightarrow').css('display', 'block');
    $('#leftarrow').animate({left: '-30px'}, 'slow');
});
$('#slider').mouseleave(function() {
    $('#leftarrow').delay(50000).css('display', 'none');
});

});

推荐答案

对于后代:从上面的注释线程来看,问题似乎不在运行 的网页中,这是警告编辑源代码时出现在Brackets编辑器中的消息.警告是JSLint错误-默认情况下,括号会在JS文件上自动运行JSLint.而且,默认情况下,只要您引用未在同一文件中定义 的全局变量,JSLint就会默认发出警告.

For posterity: from the comment thread above, it sounds like the problem wasn't in running the web page, it was warning messages that appeared in the Brackets editor while editing the source code. The warnings are JSLint errors - Brackets runs JSLint automatically on JS files by default. And JSLint warns by default any time you reference a global variable that wasn't defined in the same file.

为避免此类错误,请在此处查看我对类似问题的回答:

To avoid errors like this, see my answer to a similar question here: How to get brackets to ignore particular repeating errors?

您还可以完全取消JSLint,只需取消选中查看">"Lint文件保存" 菜单项.或者,您也可以通过单击错误显示面板右上角的"X"来使错误不太明显.那么您只会看到一个细微的状态栏图标,告诉您是否发现了JSLint错误(黄色的!"三角形)(绿色的选中标记).

You can also turn JSLint off completely just by unchecking the View > Lint Files on Save menu item. Or you can make the errors less obtrusive by clicking the "X" in the upper-right of the error display panel – then you'll only see a subtle status bar icon telling you whether JSLint errors were found (yellow "!" triangle) or not (green checkmark).

这篇关于jQuery在括号编辑器上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆