Метка: html
CSS
.popup_tooltip { position: absolute; z-index: 999; left: -9999px; background-color: #222; padding: 5px 10px; width: 250px; color: #fff; border-radius: 5px; } .popup_tooltip p { margin: 0; }
JS
function simple_tooltip(target_items, name){ $(target_items).each(function(i){ $("body").append("<div class='popup_"+name+"' id='" + name + i + "'><p>" + $(this).attr('title') + "</p></div>"); var my_tooltip = $("#" + name + i); $(this).removeAttr("title").mouseover(function(){ my_tooltip.css({opacity: 0.8, display: "none"}).fadeIn(400); }).mousemove(function(kmouse){ my_tooltip.css({left: kmouse.pageX + 15, top: kmouse.pageY + 15}); }).mouseout(function(){ my_tooltip.fadeOut(400); }); }); } // Использовать так: $(document).ready(function(){ simple_tooltip("a.tooltip", "tooltip"); });
jQuery.fn.ForceNumericOnly = function() { return this.each(function() { jQuery(this).keydown(function(e) { var key = e.charCode || e.keyCode || 0; // allow backspace, tab, delete, enter, arrows, numbers and keypad numbers ONLY // home, end, period, and numpad decimal return ( key == 8 || key == 9 || key == 13 || key == 46 || key == 110 || key == 190 || (key >= 35 && key <= 40) || (key >= 48 && key <= 57) || (key >= 96 && key <= 105)); }); }); };
Использовать так:
jQuery(document).ready(function($){ $("#yourTextBoxName").ForceNumericOnly(); });
Источник: https://stackoverflow.com/questions/995183/how-to-allow-only-numeric-0-9-in-html-inputbox-using-jquery