點擊文本框彈出窗口 選擇窗口里面文字


<script type="text/javascript">
$(function () {
$("#input").click(function () {
$("#open,#close").show();
});
$("#close").click(function () {
$("#open,#close").hide();
});
$(".list").click(function () {
$("#input").val($(this).html());
$("#open,#close").hide();
});
});
</script>

<style type="text/css">
#close{width:100%;height:100%;position:fixed;z-index:8888;margin:0;padding:0;display:none;}
#open{background-color:#efefef;width:200px;height:200px;z-index:9999;position:absolute;;display:none;}
.list{margin-left:15px;cursor:pointer;} 
</style>

html:

<input type="text" id="input"/>
<div id="open">
<span class="list">文字1</span>
<span class="list">文字2</span>
<span class="list">文字3</span>
</div>
//close為透明背景層,為了點擊open以外地方open關閉。
<div id="close"></div>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM