jquery实现点击文本框显示热门标签关键词效果

1个月前 (03-29 17:13)阅读35回复0
大陆
大陆
  • 管理员
  • 发消息
  • 注册排名1
  • 经验值3919
  • 级别管理员
  • 主题783
  • 回复2
楼主

通过jquery来实现点击文本框弹出常用热门标签和关键词列表效果,在弹出的列表上面带有关闭按钮。

<!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>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren">
<meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。">
<title>jquery实现点击文本框显示热门标签关键词效果_武鸣人</title>
<style type="text/css">
body {
font-size:12px;
}
#www_wuming_ren {
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;
}
#www_wuming_ren p {
text-align:left;
line-height:22px;
padding:2px 0;
margin:0;
border:0;
}
#www_wuming_ren span {
font-weight:bold;
}
#www_wuming_ren 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="/img/jquery_wuming_ren.js"></script>
<script language="javascript">
(function($){
$.fn.bgIframe = $.fn.bgiframe = function(s) {
// This is only for IE6
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;
};//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
})(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(){
$("#wuming_ren").selectCity("#www_wuming_ren");
});//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
//为文本域连续赋值
function checktag(o){
  var tagid = function(id){return document.getElementById(id);}
  var tags = [];//存放标签,避免重复加入
  var tagidSPLITCHAR = ' ';//设定分隔符,根据程序需求可改
  var d = tagid('wuming_ren');
  if (d.value)
    tags = d.value.split(tagidSPLITCHAR);
  var v = o.innerHTML;//如果tag有别的值或者别的非innerHTML里体现的内容
    var s = tagidSPLITCHAR+tags.join(tagidSPLITCHAR)+tagidSPLITCHAR
    if (!new RegExp(tagidSPLITCHAR+v+tagidSPLITCHAR,'g').test(s)){
      s+=v;
    }
//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
    s = s.replace(new RegExp("(^"+tagidSPLITCHAR+"*|"+tagidSPLITCHAR+"*tagid)","g"),'');
    d.value = s;
    tags = s.split(tagidSPLITCHAR);
}//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
 </script>
</head>
<body>
<a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr>
<!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。-->
<script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script>
<script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script>
需要加载js文件,请刷新后看效果。<br />
<input type="text" id="wuming_ren" name="m_tagsname" class="m_tagsname" style="width:577px" value="武鸣人网提示您,点击这里看效果" onClick="if(this.value=='武鸣人网提示您,点击这里看效果'){this.value='';this.className='m_tagsname'}">
<div id="www_wuming_ren" style="display:none">
  <div id="tagClose">关闭</div>
  <p><span>温馨提示:</span>标签间请用“空格”、“逗号”或“分号”隔开,用简练的词语概括您的博文内容。</p>
  <p><span>热门标签:</span><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)">武鸣人四号</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)">武鸣人八号</a><a href="javascript:void(0)" onClick="checktag(this)">武鸣人九号</a><a href="javascript:void(0)" onClick="checktag(this)">武鸣人十号</a></p>
  <p><span>您使用过的标签:</span><a href="javascript:void(0)" onClick="checktag(this)">彩s妆</a><a href="javascript:void(0)" onClick="checktag(this)">美sf发</a><a href="javascript:void(0)" onClick="checktag(this)">美优s博客</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)">美优博客</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)">美优博客</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)">彩妆</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)">美发</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)">武鸣人</a></p>
</div>
</body>
</html>


0
0
收藏0
回帖

jquery实现点击文本框显示热门标签关键词效果 期待您的回复!

取消
载入表情清单……
载入颜色清单……
插入网络图片

取消确定

图片上传中
编辑器信息
提示信息