帮助中心
获取牛币
联系我们
关于我们
版权声明
素材牛首页
微博登录
QQ登录
微信扫码登录
注册
登录
新浪微博
QQ登陆
微信登录
热门搜索:
小程序
支付
Java
后台模板
上传
商城模板
jQuery
手机
Thinkphp
微信
Vue.js
首 页
网页特效
整站源码
PHP实例
网站模版
工具箱
常用代码
论坛
游戏源码
资源分享
当前位置:
首页
»
精选常用代码
» JS点击开关显示或者隐藏input文本框
JS点击开关显示或者隐藏input文本框
浏览:1283次
-
评论:0次
-
发布时间:2017-06-14
Html
Css
Js
选择按钮:
input[type="checkbox"].iswitch { font-size: 10px; position: relative; display: inline-block; width: 38px; height: 22px; line-height: 22px; border-radius: 11px; padding: 0; box-shadow: inset 0 0 0 1px #a4a4a4; outline: 1px solid transparent !important; cursor: pointer; border: none; background: #cccccc; user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-touch-callout: none; -webkit-appearance: none; -moz-appearance: none; appearance: none; margin-right: 4px; margin-bottom: 7px; transition: box-shadow 0.3s ease-in-out, padding 0.25s ease-in-out; transition-delay: .1s, 0s; /* Animations if supported */ } input[type="checkbox"].iswitch:checked { transition-delay: 0s, 0s; box-shadow: inset 0 0 0 12.57142857px #ccc !important; padding-left: 16px; } input[type="checkbox"].iswitch.iswitch-secondary:checked { box-shadow: inset 0 0 0 12.57142857px #5cae6c !important; } input[type="checkbox"].iswitch:before, input[type="checkbox"].iswitch:after { content: ""; } input[type="checkbox"].iswitch:after { position: absolute; top: -6px; left: -6px; bottom: -6px; right: -6px; } input[type="checkbox"].iswitch:before { display: inline-block; height: 18px; width: 18px; margin: 2px 0 0 2px; background-color: #ffffff; border-radius: 9px; box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 0 1px 1px rgba(0, 0, 0, 0.1); -webkit-transition: all .1s ease .1s; -moz-transition: all .1s ease .1s; -o-transition: all .1s ease .1s; transition: all .1s ease .1s; } ::-webkit-input-placeholder { color: #707070; } ::-moz-placeholder { color: #707070; } :-moz-placeholder { color: #707070; } .section-other { padding: 22px 5% 0px; } .check-input { margin-top: -3px; float: right; } .other-charge { color: #575757; font-size: 15px; } .other-middle { border: 1px dashed #ccc; background: #fff; padding: 14px 14px 0; position: relative; margin-top: 20px; } .other-middle:before { position: absolute; content: " "; border-top: 1px dashed #ccc; border-right: 1px dashed #ccc; background: #fff; -webkit-transform: rotate(-45deg); transform: rotate(-45deg); left: 31px; top: -6px; width: 10px; height: 10px; } .input_div { border: #c9c9c9 solid 1px; border-radius: 5px; background: #fff; padding: 7px 0; box-sizing: border-box; margin-bottom: 14px; } .input_div input { width: 100%; height: 20px; background-color: transparent; color: #575757; vertical-align: middle; font-size: 13px; line-height: 20px; padding-left: 10px; box-sizing: border-box; outline: none; border: none; }
function mySwitch() { var other_middle=document.getElementById('other-middle'); var other_middle=document.getElementById('other-middle'); other_middle.style.display = other_middle.style.display == 'none' ? 'block' : 'none'; } window.onload = function () { var isreceipt = document.getElementById("isreceipt"); isreceipt.onclick = function () { mySwitch(); } }
↑上面代码改变,会自动显示代码结果
jQuery调用版本:
1.11.3
<!doctype html><html><head><meta charset="utf-8"><title>JS点击开关显示或者隐藏input文本框-www.sucainiu.com</title><script src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script><style>
</style></head><body>
<script>
</script>
</body></html>
立即下载
收藏
积分说明:注册即送10牛币,每日签到可获得5牛币,成为VIP会员可永久免牛币下载!
充值积分
充值会员
更多说明»
代码描述:这种需求在应用中也是比较常见的,只是形式上的不同而已,实质是大同小异。下面就分享一个这样的代码,点击右侧的开关按钮可以实现底部文本框的显示或者隐藏。
美观开关按钮代码实例
jQuery下雨效果
讨论这个常用代码(0)
回答他人问题或分享心得会奖励牛币
〒_〒 居然一个评论都没有……
文明上网,理性发言! 😉 阿里云幸运券,
戳我领取
发表评论
提交回复
我的积分余额:
0
已下载次数:
1283
所需牛币:
5
开始下载
牛币获取:
签到、评论、充值
» 在线充值
(10牛币=1元)
成为VIP可永久免积分下载全部常用代码
» 查看详情
VIP
客服
签到
充值