此时元素div上不允许使用属性名称 [英] Attribute name not allowed on element div at this point

查看:95
本文介绍了此时元素div上不允许使用属性名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<!DOCTYPE html>
<html>
    <head>
        <title>jGrowl</title>

        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>     
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>

        <script type="text/javascript" src="data/awo-jgrowl.js"></script>
        <script type="text/javascript" src="data/shortcut.js"></script>

        <link rel="stylesheet" type="text/css" href="data/awo-jgrowl.css">

        <script type="text/javascript">
            $(document).ready(function() {
                $('div[name=message]').awomsg('Input message', {sticky: true});
            });

            shortcut.add("m",function() {
                $('div[name=message]').awomsg('Input message', {sticky: true});
            });

            shortcut.add("h",function() {
                alert('ur doin it wrong');
            });
        </script>

    </head>
    <body>
        <div name="message" class="jGrowl bottom-right errorGrowl"></div>
    </body> 
</html>

您好,我收到一个w3c错误,我无法理解:

Hello, i am getting a w3c error that i can't understand:

第31行,第61列:元素div在此时不允许使用的属性名称。

Line 31, Column 61: Attribute name not allowed on element div at this point.

就是这一行:

<div name="message" class="jGrowl bottom-right errorGrowl"></div>


推荐答案

错误消息似乎很自我解释。您不能在 div 标签上拥有名称属性。因此,您的代码可能如下所示:

The error message seems pretty self explanatory. You cannot have a name attribute on a div tag. So your code could look like this:

<div id="message" class="jGrowl bottom-right errorGrowl"></div>

然后使用id选择器:

and then use id selectors:

$('div#message')...

这篇关于此时元素div上不允许使用属性名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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