jQuery實作資訊提示框(有圓角框與動畫)效果_jquery
本文實例講述了jQuery實作資訊提示框效果。分享給大家供大家參考。具體如下:
一個jquery提示框特效,黑色風可,且提示框是圓角形狀,點選頁面中間的幾個文字,提示框資訊就會動態顯示,CSS和JS部分程式碼比較多。
先來看看運行效果如下:
具體程式碼如下:
<!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jQuery实现的非常人性化的提示信息框效果</title> <script type="text/javascript" src="jquery-1.6.2.min.js"></script> <script type="text/javascript"> var humanMsg = { setup: function(appendTo, logName, msgOpacity) { humanMsg.msgID = 'humanMsg'; humanMsg.logID = 'humanMsgLog'; if (appendTo == undefined) appendTo = 'body'; if (logName == undefined) logName = 'Message Log'; humanMsg.msgOpacity = .8; if (msgOpacity != undefined) humanMsg.msgOpacity = parseFloat(msgOpacity); jQuery(appendTo).append('<div id="'+humanMsg.msgID+'" class="humanMsg"><div class="round"></div><p></p><div class="round"></div></div> <div id="'+humanMsg.logID+'"><p>'+logName+'</p><ul></ul></div>') jQuery('#'+humanMsg.logID+' p').click( function() { jQuery(this).siblings('ul').slideToggle() } ) }, displayMsg: function(msg) { if (msg == '') return; clearTimeout(humanMsg.t2); jQuery('#'+humanMsg.msgID+' p').html(msg) jQuery('#'+humanMsg.msgID+'').show().animate({ opacity: humanMsg.msgOpacity}, 200, function() { jQuery('#'+humanMsg.logID) .show().children('ul').prepend('<li>'+msg+'</li>') .children('li:first').slideDown(200) if ( jQuery('#'+humanMsg.logID+' ul').css('display') == 'none') { jQuery('#'+humanMsg.logID+' p').animate({ bottom: 40 }, 200, 'linear', function() { jQuery(this).animate({ bottom: 0 }, 300, 'easeOutBounce', function() { jQuery(this).css({ bottom: 0 }) }) }) } }) humanMsg.t1 = setTimeout("humanMsg.bindEvents()", 700) humanMsg.t2 = setTimeout("humanMsg.removeMsg()", 5000) }, bindEvents: function() { jQuery(window) .mousemove(humanMsg.removeMsg) .click(humanMsg.removeMsg) .keypress(humanMsg.removeMsg) }, removeMsg: function() { // Unbind mouse & keyboard jQuery(window) .unbind('mousemove', humanMsg.removeMsg) .unbind('click', humanMsg.removeMsg) .unbind('keypress', humanMsg.removeMsg) if (jQuery('#'+humanMsg.msgID).css('opacity') == humanMsg.msgOpacity) jQuery('#'+humanMsg.msgID).animate({ opacity: 0 }, 500, function() { jQuery(this).hide() }) } }; jQuery(document).ready(function(){ humanMsg.setup(); }) </script> <style> html, body { height: 100%; /* Damn you IE! */ } .humanMsg { font: normal 20px/50px Helvetica, Arial, Sans-Serif; letter-spacing: -1px; position: fixed; top: 130px; left: 25%; width: 50%; color: white; background-color: black; text-align: center; display: none; opacity: 0; z-index: 100000; } .humanMsg .round { border-left: solid 2px white; border-right: solid 2px white; font-size: 1px; height: 2px; } .humanMsg p { padding: .3em; display: inline; } .humanMsg a { display: none; } #humanMsgLog { font: normal 10px Helvetica, Arial, Sans-Serif; color: white; position: fixed; bottom: 0; left: 0; width: 100%; max-height: 200px; display: none; z-index: 10000; } #humanMsgLog p { position: relative; left: 50%; width: 200px; margin: 0; margin-left: -100px; padding: 0 10px; line-height: 20px; background: #333; text-align: center; white-space: pre; cursor: pointer; } #humanMsgLog p:hover { background: #222; } #humanMsgLog ul { margin: 0; padding: 0; position: relative; max-height: 180px; overflow: auto; display: none; } #humanMsgLog ul li { color: #555; font-size: 12px; list-style-type: none; border-bottom: 1px solid #ddd; line-height: 40px; display: none; padding: 0 20px; position: relative; overflow: hidden; white-space: pre; } #humanMsgLog ul li:hover { background: #f2f2f2; } #humanMsgLog ul li:first-child { margin-top: 1px; } #humanMsgLog ul li .error { color: orangered; } #humanMsgLog ul li .indent { position: absolute; top: 0; left: 100px; margin-right: 200px; height: inherit; } </style> <script> jQuery(document).ready(function() { jQuery('a.showmessage').click(function() { humanMsg.displayMsg('<strong>Success:</strong> <span class="indent">You clicked \''+jQuery(this).text()+'\'</span>'); return false; }) jQuery('a.showmessage:last').click(function() { humanMsg.displayMsg('"Your <strong>Earth</strong> will be reduced to a burned-out cinder."'); return false; }) }) </script> <style> p.links { position: absolute; font: 2em Helvetica, Arial, Sans-Serif; top: 40%; left: 50%; width: 400px; margin-left: -200px; text-align: center; } p.links a { text-decoration: none; color: #888; } p.links a:hover { color: #222; } p.links a.home { font-size: 10px; line-height: 30px; } </style> </head> <body> <p class="links"> <a href="#" class="showmessage">Klaatu</a> <a href="#" class="showmessage">Barada</a> <a href="#" class="showmessage">Nikto</a><br /> <a href="http://www.jb51.net/" class="home">Humanized Messages</a> </p> </body> </html>
希望本文所述對大家的jquery程式設計有所幫助。

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

jQuery引用方法詳解:快速上手指南jQuery是一個受歡迎的JavaScript庫,被廣泛用於網站開發中,它簡化了JavaScript編程,並為開發者提供了豐富的功能和特性。本文將詳細介紹jQuery的引用方法,並提供具體的程式碼範例,幫助讀者快速上手。引入jQuery首先,我們需要在HTML檔案中引入jQuery函式庫。可以透過CDN連結的方式引入,也可以下載

jQuery中如何使用PUT請求方式?在jQuery中,發送PUT請求的方法與發送其他類型的請求類似,但需要注意一些細節和參數設定。 PUT請求通常用於更新資源,例如更新資料庫中的資料或更新伺服器上的檔案。以下是在jQuery中使用PUT請求方式的具體程式碼範例。首先,確保引入了jQuery庫文件,然後可以透過以下方式發送PUT請求:$.ajax({u

標題:jQuery小技巧:快速修改頁面所有a標籤的文字在網頁開發中,我們經常需要對頁面中的元素進行修改和操作。使用jQuery時,有時候需要一次修改頁面中所有a標籤的文字內容,這樣可以節省時間和精力。以下將介紹如何使用jQuery快速修改頁面所有a標籤的文本,同時給出具體的程式碼範例。首先,我們需要引入jQuery庫文件,確保在頁面中引入了以下程式碼:<

jQuery如何移除元素的height屬性?在前端開發中,經常會遇到需要操作元素的高度屬性的需求。有時候,我們可能需要動態改變元素的高度,而有時候又需要移除元素的高度屬性。本文將介紹如何使用jQuery來移除元素的高度屬性,並提供具體的程式碼範例。在使用jQuery操作高度屬性之前,我們首先需要了解CSS中的height屬性。 height屬性用於設定元素的高度

標題:使用jQuery修改所有a標籤的文字內容jQuery是一款受歡迎的JavaScript庫,被廣泛用於處理DOM操作。在網頁開發中,經常會遇到需要修改頁面上連結標籤(a標籤)的文字內容的需求。本文將介紹如何使用jQuery來實現這個目標,並提供具體的程式碼範例。首先,我們需要在頁面中引入jQuery庫。在HTML檔案中加入以下程式碼:

jQuery是一種流行的JavaScript庫,被廣泛用於處理網頁中的DOM操作和事件處理。在jQuery中,eq()方法是用來選擇指定索引位置的元素的方法,具體使用方法和應用場景如下。在jQuery中,eq()方法選擇指定索引位置的元素。索引位置從0開始計數,即第一個元素的索引是0,第二個元素的索引是1,依此類推。 eq()方法的語法如下:$("s

如何判斷jQuery元素是否具有特定屬性?在使用jQuery操作DOM元素時,常會遇到需要判斷元素是否具有某個特定屬性的情況。在這種情況下,我們可以藉助jQuery提供的方法來輕鬆實現這項功能。以下將介紹兩種常用的方法來判斷一個jQuery元素是否具有特定屬性,並附上具體的程式碼範例。方法一:使用attr()方法和typeof運算子//判斷元素是否具有特定屬

jQuery是一個受歡迎的JavaScript函式庫,廣泛用於網頁開發。在網頁開發過程中,經常需要透過JavaScript動態地在表格中新增一行。本文將介紹如何使用jQuery為表格新增一行,並提供具體的程式碼範例。首先,我們需要在HTML頁面中引入jQuery函式庫。可以透過以下程式碼在標籤中引入jQuery庫:
