气球不显示(Jquery气球插件)

时间:2014-07-13 07:01:18

标签: jquery balloon

您是否尝试过此jquery气球工具提示插件?

jquery.balloon.js Demo page

我计划用它来通知用户某个文本框上允许仅限数字。

js code

function isNotDigit(key_event) {
return (key_event.which != 8 && key_event.which != 0 && (key_event.which < 48 || key_event.which > 57));
}
function isDigit(key_event) { return (!(isNotDigit(key_event)))}
$(document).ready(function () {
$("#atkFld").keypress(function (e0) {
    if (isNotDigit(e0)) {
        $(this).balloon({contents: 'Numbers Only!'});
        //$(this).next().html("Numbers Only").show().fadeOut("slow"); //Original code
        return false;
      }
  });
});

html代码

<input name="Attack" type="text" id="atkFld" placeholder="ATK" required />

它不接受气球显示的字母/字符串/字符,但是当您将鼠标移出并再次悬停在文本框上时它会出现

1 个答案:

答案 0 :(得分:0)

试试这个。

CSS:

a[bubbletooltip]:link, a[bubbletooltip]:visited
    {
            text-decoration: none;
            position: relative;
            color : white;
    }

    a[bubbletooltip]:before
    {
            content: "";
            position: absolute;
            border-bottom: 21px solid #424242;
            border-left: 21px solid transparent;
            border-right: 21px solid transparent;
            visibility: hidden;
            bottom: -10px;
            left: 100px;
    }

    a[bubbletooltip]:after
    {
            position: absolute;
            content: attr(bubbletooltip);
            color: #FFF;
            font-weight:bold;
            bottom: -25px;
            left: 67px;
            white-space: nowrap;
            background: #424242;
            padding: 5px 10px;
            -moz-border-radius: 6px;
            -webkit-border-radius:6px;
            -khtml-border-radius:6px;
            border-radius: 6px;
            visibility: hidden;
    }

    a[bubbletooltip]:hover:before, a[bubbletooltip]:hover:after
    {
            visibility: visible;
            -moz-transition: visibility 0s linear .3s;
    }

查看:

<a href="#" bubbletooltip="text inside balloon."></a>