jquery搜尋下拉提示框/登陸賬號下拉提示框

disable發表於2021-09-09


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""><html xmlns=""><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">body{font-size:12px;}.selectItemcont{padding:8px;}#selectItem{border:1px solid #f00;background:#FFF;position:absolute;top:0px;left:center;overflow:hidden;width:240px;z-index:1000;}.selectItemhidden{display:none;}</style><script type="text/javascript" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="引入jquery庫"></script><script>(function($){    $.fn.bgIframe=$.fn.bgiframe = function(s){        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("#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(); //  2    });    return this;}$(document).ready(function(){    $("#address").selectCity("#selectItem");}) </script></head><body><input type="text" name="address" id="address" ><div id="selectItem" class="selectItemhidden">    <div id="selectItemCount" class="selectItemcont">        <div id="selectSub">            <input type="checkbox" name="cr01"  id="cr01" value="搜尋記錄1"/><label for="cr01">搜尋記錄1</label><br />            <input type="checkbox" name="cr02"  id="cr02" value="搜尋記錄2"/><label for="cr02">搜尋記錄2</label><br />            <input type="checkbox" name="cr03"  id="cr03" value="登陸賬號3"/><label for="cr03">登陸賬號3</label><br />            <input type="checkbox" name="cr04"  id="cr04" value="登陸賬號4"/><label for="cr04">登陸賬號4</label><br />            清除歷史記錄...        </div>    </div></div></body></html>


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/200/viewspace-2815520/,如需轉載,請註明出處,否則將追究法律責任。

相關文章