国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jQuery實現(xiàn)點擊文本框彈出熱門標(biāo)簽的提示效果

2019-11-20 21:40:42
字體:
供稿:網(wǎng)友
復(fù)制代碼 代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery實現(xiàn)點擊文本框彈出熱門標(biāo)簽的提示示例_網(wǎng)頁代碼站</title>
<style type="text/css">
body {
font-size:12px;font-family:Arial;
}
#m_tagsItem {
background:#fff;
position:absolute;
top:0px;
left:0px;
overflow:hidden;
width:590px;
*width:561px;
width:561px/9;
padding:10px;
border:1px solid #ccc;
z-index:1000;
display:none;
}
#m_tagsItem p {
text-align:left;
line-height:22px;
padding:2px 0;
margin:0;
border:0;
}
#m_tagsItem span {
font-weight:bold;
}
#m_tagsItem a {
margin:0 5px;
}
.m_tagsname {
color:#999;
vertical-align:middle;
font-size:12px;
text-indent:3px;
line-height:20px;
}
#tagClose {
font-size:12px;
color:#888;
cursor:pointer;
position:absolute;
top:2px;
right:2px;
}
</style>
<script src="http://www.webdm.cn/themes/script/jquery.js"></script>
<script language="javascript">
(function ($) {
$.fn.bgIframe = $.fn.bgiframe = function (s) {
if ($.browser.msie && /6.0/.test(navigator.userAgent)) {
s = $.extend({
top: 'auto', // auto == .currentStyle.borderTopWidth
left: 'auto', // auto == .currentStyle.borderLeftWidth
width: 'auto', // auto == offsetWidth
height: 'auto', // auto == offsetHeight
opacity: true,
src: 'javascript:false;'
}, s || {});
var prop = function (n) { return n && n.constructor == Number ? n + 'px' : n; },
html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="' + s.src + '"' +
'style="display:block;position:absolute;z-index:-1;' +
(s.opacity !== false ? 'filter:Alpha(Opacity=/'0/');' : '') +
'top:' + (s.top == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+/'px/')' : prop(s.top)) + ';' +
'left:' + (s.left == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+/'px/')' : prop(s.left)) + ';' +
'width:' + (s.width == 'auto' ? 'expression(this.parentNode.offsetWidth+/'px/')' : prop(s.width)) + ';' +
'height:' + (s.height == 'auto' ? 'expression(this.parentNode.offsetHeight+/'px/')' : prop(s.height)) + ';' +
'"/>';
return this.each(function () {
if ($('> iframe.bgiframe', this).length == 0)
this.insertBefore(document.createElement(html), this.firstChild);
});
}
return this;
};
})(jQuery);
jQuery.fn.selectCity = function (targetId) {
var _seft = this;
var targetId = $(targetId);
this.click(function () {
var A_top = $(this).offset().top + $(this).outerHeight(true); // 1
var A_left = $(this).offset().left;
targetId.bgiframe();
targetId.show().css({ "position": "absolute", "top": A_top + "px", "left": A_left + "px" });
});
targetId.find("#tagClose").click(function () {
targetId.hide();
});
$(document).click(function (event) {
if (event.target.id != _seft.selector.substring(1)) {
targetId.hide();
}
});
targetId.click(function (e) {
e.stopPropagation(); // 2
});
return this;
}
$(function () {
$("#selecttags").selectCity("#m_tagsItem");
});
//為文本域連續(xù)賦值
function checktag(o) {
var tagid = function (id) { return document.getElementById(id); }
var tags = []; //存放標(biāo)簽,避免重復(fù)加入
var tagidSPLITCHAR = ' '; //設(shè)定分隔符,根據(jù)程序需求可改
var d = tagid('selecttags');
if (d.value)
tags = d.value.split(tagidSPLITCHAR);
var v = o.innerHTML; //如果tag有別的值或者別的非innerHTML里體現(xiàn)的內(nèi)容
var s = tagidSPLITCHAR + tags.join(tagidSPLITCHAR) + tagidSPLITCHAR
if (!new RegExp(tagidSPLITCHAR + v + tagidSPLITCHAR, 'g').test(s)) {
s += v;
}
s = s.replace(new RegExp("(^" + tagidSPLITCHAR + "*|" + tagidSPLITCHAR + "*tagid)", "g"), '');
d.value = s;
tags = s.split(tagidSPLITCHAR);
}
</script>
</head>
<body>
如果沒有出現(xiàn)提示框請刷新一下頁面再試~
<input type="text" id="selecttags" name="m_tagsname" class="m_tagsname" style="width: 577px"
value="點擊查看熱門標(biāo)簽和您曾經(jīng)使用過的標(biāo)簽" onclick="if(this.value=='點擊查看熱門標(biāo)簽和您曾經(jīng)使用過的標(biāo)簽'){this.value='';this.className='m_tagsname'}">
<div id="m_tagsItem" style="display: none">
<div id="tagClose">
關(guān)閉</div>
<p>
<span>溫馨提示:</span>標(biāo)簽間請用“空格”、“逗號”或“分號”隔開,用簡練的詞語概括您的博文內(nèi)容。</p>
<p>
<span>熱門標(biāo)簽:</span><a href="javascript:void(0)" onclick="checktag(this)">彩妝</a><a
href="javascript:void(0)" onclick="checktag(this)">美發(fā)</a><a href="javascript:void(0)"
onclick="checktag(this)">美優(yōu)博客</a><a href="javascript:void(0)" onclick="checktag(this)">aaa</a><a
href="javascript:void(0)" onclick="checktag(this)">bbb</a><a href="javascript:void(0)"
onclick="checktag(this)">天堂</a><a href="javascript:void(0)" onclick="checktag(this)">eee</a><a
href="javascript:void(0)" onclick="checktag(this)">fff</a><a href="javascript:void(0)"
onclick="checktag(this)">ggg</a></p>
<p>
<span>您使用過的標(biāo)簽:</span><a href="javascript:void(0)" onclick="checktag(this)">軟件</a><a
href="javascript:void(0)" onclick="checktag(this)">Delphi</a><a href="javascript:void(0)"
onclick="checktag(this)">博客</a><a href="javascript:void(0)" onclick="checktag(this)">源碼</a><a
href="javascript:void(0)" onclick="checktag(this)">彩妝</a><a href="javascript:void(0)"
onclick="checktag(this)">google</a><a href="javascript:void(0)" onclick="checktag(this)">新浪</a></p>
</div>
<br />
<p>
<a >網(wǎng)頁代碼站</a> - 最專業(yè)的網(wǎng)頁代碼下載網(wǎng)站 - 致力為中國站長提供有質(zhì)量的網(wǎng)頁代碼!</p>
</body>

</html>
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 建德市| 玉田县| 当涂县| 巧家县| 达孜县| 云梦县| 北京市| 马山县| 仪陇县| 丰都县| 黄大仙区| 海淀区| 兴义市| 万源市| 大方县| 芒康县| 湘潭市| 中超| 克拉玛依市| 台湾省| 闽侯县| 涞源县| 桂林市| 西昌市| 大埔区| 井陉县| 巨野县| 边坝县| 泾阳县| 乐亭县| 左云县| 崇文区| 海晏县| 抚宁县| 五家渠市| 易门县| 汪清县| 司法| 百色市| 赤峰市| 东莞市|