你试过这个 jquery 气球工具提示插件吗?
我打算用它来通知用户在某个文本框中只允许使用数字。
js代码
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 />
它不接受气球显示的字母/字符串/字符,但是当您将鼠标移出并再次悬停在文本框上时,它会出现