时间:2021-05-26
案例:模拟京东快递单号的查询效果,供大家参考,具体内容如下
要求:当我们在文本框中输入内容时,文本框上面自动显示大字号的内容
分析:
注意:keydown 和 keypress 在文本框里面的特点 : 他们两个事件触发的时候,文字还没有落入文本框中,keyup 事件触发的时候,文本已经落入文本框里了
<style> * { padding: 0; margin: 0; } .search { position: relative; width: 178px; margin: 100px; } .con { display: none; position: absolute; top: -48px; width: 171px; border: 1px solid rgba(0, 0, 0, 0.2); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); padding: 5px 0; font-size: 18px; line-height: 20px; color: #333; } .con::before { content: ""; width: 0; height: 0; position: absolute; top: 28px; left: 18px; border: 8px solid #000; border-style: solid dashed dashed; border-color: #fff transparent transparent; } </style> </head> <body> <div class="search"> <div class="con"></div> <input type="text" placeholder="请输入您的快递单号" class="jd" /> </div> <script> var con = document.querySelector(".con"); var jd_input = document.querySelector(".jd"); jd_input.addEventListener("keyup", function () { if (this.value == "") { con.style.display = "none"; } else { con.style.display = "block"; con.innerHTML = this.value; } }); //当失去焦点,就隐藏盒子 jd_input.addEventListener("blur", function () { con.style.display = "none"; }); //当获得焦点,就显示盒子 jd_input.addEventListener("focus", function () { if (this.value !== "") { con.style.display = "block"; } }); </script></body>以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
京东商城物流运输范畴怎么查询?在哪儿查?京东快递服务电话多少钱?一起看下!1、百度一下京东快递点击下边的【京东快递,京东快递单号查询-京东商城快递官网】连接进到
本文实例为大家分享了JS实现京东快递单号查询的具体代码,供大家参考,具体内容如下Document*{margin:0;padding:0;}.search{po
吾爱全国快递查询是一款绿色免费的快递单号查询工具,支持查询顺丰、圆通、申通、汇通、天天、韵达等国内所有的快递单号,并且可以自动识别快递单号类型,查询速度非常快,
快递补发单号查询的方法是:卖家会提供快递单号,登录物流公司官网,输入快递单号即可查询,也可以根据手机号查询。快递使用注意事项: 1、收到快递后最好将包含个人信
寄件人查询方法1、一般每个快递包裹都有快递单号,通过快递单号就可以专查询相关物流信息。但属快递单号只能查询物品从哪里发出的以及物流,看不到寄件者。2、如果是淘宝