简体   繁体   English

使用jQuery在元素上显示气球消息

[英]Balloon message on element using jQuery

I want to show balloon message with a title when I mouse over some element in my site. 当我将鼠标悬停在网站中的某些元素上时,我想显示带有标题的气球消息。 I see jQuery code but I don't know if I used it in a correct way or not. 我看到了jQuery代码,但不知道是否以正确的方式使用它。

This is my code: 这是我的代码:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
</script>
<script type="text/javascript" src="./js/jquery.balloon.js">
</script>

<script>
    $(document).ready($(function() {
        $('#style1').balloon({ position: "bottom right"});
    });
</script>
</head>
<body>
    <div id="wrap">

        <button id="style1" onclick="getValue('./CSS/style1.css')">style1</button>

    </div>
</body>

can you help me this link i used http://file.urin.take-uma.net/jquery.balloon.js-Demo.html 您能帮我这个链接吗,我用过http://file.urin.take-uma.net/jquery.balloon.js-Demo.html

There are a couple things that could be wrong and some certainties. 有几件事情可能是错误的,并且可以肯定。

  • The balloon plugin only makes a balloon if the target element has a title attribute. 仅当目标元素具有title属性时,气球插件才会制作气球。 Your button doesn't. 您的button没有。

    Make sure it has a title attribute. 确保它具有title属性。

  • Make sure your js file exists at given location ./js/jquery.balloon.js , try pressing f12 and go to the console tab and see if you spot any errors. 确保您的js文件位于给定位置./js/jquery.balloon.js ,请尝试按f12并转到控制台选项卡,看看是否发现任何错误。

Add title attribute to your button 将标题属性添加到您的按钮

        <button id="style1" onclick="getValue('./CSS/style1.css')" title="Some">style1</button>

JsFiddle example JsFiddle示例

Title is missing. 标题丢失。 < button id="style1" onclick="getValue('./CSS/style1.css')" title="YourTitleHere" > <button id =“ style1” onclick =“ getValue('./ CSS / style1.css')” title =“ YourTitleHere” >>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
</script>
<script type="text/javascript" src="./js/jquery.balloon.js">
</script>

<script>
    $(document).ready($(function() {
        $('#style1').balloon({ position: "bottom right"});
    });
</script>
</head>
<body>
    <div id="wrap">
<button id="style1" onclick="getValue('./CSS/style1.css')" title="YourTitleHere">style1</button>

    </div>
</body>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM