首页 / JQUERY / jquery input选择弹框
jquery input选择弹框
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了jquery input选择弹框,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含7164字,纯文字阅读大概需要11分钟。
内容图文
index.jsp
<% @ page language = " java " contentType = " text/html; charset=UTF-8 " pageEncoding = " UTF-8 " %> <! DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" > < html > < head > < meta http-equiv ="Content-Type" content ="text/html; charset=UTF-8" > < title >Insert title here</title><script type="text/javascript" src="jquery-1.7.2.min.js"></script><script type="text/javascript" src="jquery.plugin.js"></script><link rel="stylesheet" type="text/css" href="jquery.plugin.css"/><script type="text/javascript"> jQuery.fn.selectCity =function(targetId) { var _seft =this; var targetId = $(targetId); this.click(function() { var A_top = $(this).offset().top + $(this).outerHeight(true); var A_left = $(this).offset().left; targetId.bgiframe(); targetId.show().css({ "position" : "absolute", "top" : A_top +"px", "left" : A_left +"px" }); }); targetId.find("#selectItemClose").click(function() { targetId.hide(); }); targetId.find("#selectSub :checkbox").click(function() { targetId.find(":checkbox").attr("checked", false); $(this).attr("checked", true); _seft.val($(this).val()); targetId.hide(); }); $(document).click(function(event) { if (event.target.id != _seft.selector.substring(1)) { targetId.hide(); } }); targetId.click(function(e) { e.stopPropagation(); }); returnthis; }; $(function() { $("#address").selectCity("#selectItem"); $("#address2").selectCity("#selectItem2"); }); </script></head><body><br> <input type="text" name="address" id="address" size="33"><br><div id="selectItem" class="selectItemhidden"><div id="selectItemAd" class="selectItemtit bgc_ccc"><h2 id="selectItemTitle" class="selectItemleft">请选择城市</h2><div id="selectItemClose" class="selectItemright">关闭</div></div><div id="selectItemCount" class="selectItemcont"><div id="selectSub"><input type="checkbox" name="cr01" id="cr01" value="北京1"/><label for="cr01">北京1</label><input type="checkbox" name="cr02" id="cr02" value="北京2"/><label for="cr02">北京2</label><input type="checkbox" name="cr03" id="cr03" value="北京3"/><label for="cr03">北京3</label><input type="checkbox" name="cr09" id="cr09" value="北京4"/><label for="cr09">北京4</label><input type="checkbox" name="cr09" id="cr09" value="北京4"/><label for="cr09">北京4</label><input type="checkbox" name="cr09" id="cr09" value="北京4"/><label for="cr09">北京4</label><input type="checkbox" name="cr09" id="cr09" value="北京4"/><label for="cr09">北京4</label><input type="checkbox" name="cr09" id="cr09" value="北京4"/><label for="cr09">北京4</label></div></div></div><!-- <input type="text" name="address2" id="address2" size="20"> <div id="selectItem2" class="selectItemhidden"> <div id="selectItemAd" class="selectItemtit bgc_ccc"> <h2 id="selectItemTitle" class="selectItemleft">请选择城市</h2> <div id="selectItemClose" class="selectItemright">关闭</div> </div> <div id="selectItemCount" class="selectItemcont"> <div id="selectSub"> <input type="checkbox" name="cr04" id="cr04" value="北京1" /> <label for="cr04">北京1</label> <input type="checkbox" name="cr05" id="cr05" value="北京2" /> <label for="cr05">北京2</label> <input type="checkbox" name="cr06" id="cr06" value="北京3" /> <label for="cr06">北京3</label> <input type="checkbox" name="cr07" id="cr07" value="北京4" /> <label for="cr07">北京4</label> </div> </div> </div> --></body></html>
jquery.plugin.css
body{font-size:12px;} #selectItem{background:#FFF;position:absolute;top:0px;left:center;border:1px solid #000;overflow:hidden;width:240px;z-index:1000;} .selectItemtit{line-height:20px;height:20px;margin:1px;padding-left:12px;} .bgc_ccc{background:#E88E22;} .selectItemleft{float:left;margin:0px;padding:0px;font-size:12px;font-weight:bold;color:#fff;} .selectItemright{float:right;cursor:pointer;color:#fff;} .selectItemhidden{display:none;} .selectItemcont{padding:8px;} /*.selectItemcls{clear:both;font-size:0px;height:0px;overflow:hidden;}*//*#selectItem2{background:#FFF;position:absolute;top:0px;left:center;border:1px solid #000;overflow:hidden;width:240px;z-index:1000;}*/
jquery.plugin.js
(function($){ $.fn.bgIframe = $.fn.bgiframe = function(s) { // This is only for IE6if ( $.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))+‘;‘+ ‘"/>‘; returnthis.each(function() { if ( $(‘> iframe.bgiframe‘, this).length == 0 ) this.insertBefore( document.createElement(html), this.firstChild ); }); } returnthis; }; })(jQuery);
构建的js
var selectItemhidden = jQuery("<div></div>").addClass("selectItemhidden").attr("id","selectItem"); var selectItemtit = jQuery("<div></div>").addClass("selectItemtit bgc_ccc").attr("id","selectItemAd"); var selectItemleft = jQuery("<h2></h2>").addClass("selectItemleft").attr("id","selectItemTitle"); var selectItemright = jQuery("<div></div>").addClass("selectItemright").attr("id","selectItemClose"); var selectItemcont = jQuery("<div></div>").addClass("selectItemcont").attr("id","selectItemCount"); var selectSub = jQuery("<div></div>").attr("id","selectSub"); var checkbox = jQuery("<input>").attr("type","checkbox").attr("name","cr01").attr("id","cr01").val("北京1"); var label = jQuery("<label>").attr("for","cr01").html("北京"); var title = selectItemtit.append(selectItemleft).append(selectItemright); var content = selectItemcont.append(selectSub.append(checkbox).append(label)); selectItemhidden.append(title).append(content);
原文:http://www.cnblogs.com/cxxjohnson/p/5592229.html
内容总结
以上是互联网集市为您收集整理的jquery input选择弹框全部内容,希望文章能够帮你解决jquery input选择弹框所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。