PHP選項(xiàng):ini_get_all()的用法
733
2023-12-14
采用JQuery實(shí)現(xiàn)文本框的水印效果非常容易,效果如下:
代碼片段,定義要應(yīng)用水印效果的文本框的樣式: .watermark { color: #cccccc; }
將JavaScript代碼封裝成JQuery的插件:
(function ($) { $.fn.watermark = function (options) { var settings = $.extend({ watermarkText: "Input something here", className: "watermark" }, options); return this.each(function () { if ($(this).val().length == 0 || $(this).val() == settings.watermarkText) { //init, set watermark text and class $(this).val(settings.watermarkText).addClass(settings.className); } //if blur and no value inside, set watermark text and class again. $(this).blur(function () { if ($(this).val().length == 0) { $(this).val(settings.watermarkText).addClass(settings.className); } }); //if focus and text is watermrk, set it to empty and remove the watermark class $(this).focus(function () { if ($(this).val() == settings.watermarkText) { $(this).val('').removeClass(settings.className); } }); }); } })(jQuery);
接下來直接在頁面上使用:
<div class="search_box"> <input id="tb_search" type="text" /> </div> <script type="text/javascript"> $(document).ready(function () { $("#tb_search").watermark({ watermarkText: "站內(nèi)檢索", className: "watermark", }); }); </script>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持綠夏網(wǎng)。
#免責(zé)聲明#
本站[綠夏技術(shù)導(dǎo)航]提供的一切軟件、教程和內(nèi)容信息僅限用于學(xué)習(xí)和研究目的;不得將上述內(nèi)容用于商業(yè)或者非法用途,否則,一切后果請用戶自負(fù)。本站信息來自網(wǎng)絡(luò)收集整理,版權(quán)爭議與本站無關(guān)。您必須在下載后的24個(gè)小時(shí)之內(nèi),從您的電腦或手機(jī)中徹底刪除上述內(nèi)容。如果您喜歡該程序或內(nèi)容,請支持正版,購買注冊,得到更好的正版服務(wù)。我們非常重視版權(quán)問題,如有侵權(quán)請郵件[admin@lxwl520.com]與我們聯(lián)系進(jìn)行刪除處理。敬請諒解!