html苹果风格开关,仿iPhone开关式按钮(jQuery+CSS3)

仿iPhone开关式按钮(jQuery+CSS3)

*{margin:0;padding:0;}

body{font-size:14px;color:#444;font-family:"微软雅黑",Arial;background:#fff;padding:50px;}

a{color:#444;text-decoration: none;}

a:hover{color:#065BC2;text-decoration: none;}

.clear{clear:both;}

img{border:none;vertical-align: middle;}

ul{list-style: none;}

.mwui-switch-btn{

width:84px;

display:block;

padding:1px;

background:#3B75FD;

overflow:hidden;

margin-bottom:5px;

border:1px solid #2E58C1;

border-radius:18px;

cursor: pointer;

}

.mwui-switch-btn span{

width:32px;

font-size:14px;

height:18px;

padding:4px 5px 2px 5px;

display:block;

filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#f6f6f6,endColorstr=#eeeeee,grandientType=1);

background:-webkit-gradient(linear, 0 0, 0 100%, from(#f6f6f6), to(#eeeeee));

background:-moz-linear-gradient(top, #f6f6f6, #eeeeee);

border-radius:18px;

float:left;

color:#3B75FD;

text-align:center;

}

.mwui-switch-btn:hover span{

background:#fff;

}

.mwui-switch-btn span.off{float:right;}

input[type='submit']{padding:5px 10px;cursor: pointer;}

显示图标1:

显示顶栏1:开

显示图标2:ON

显示顶栏2:OFF

$(function() {

$('.mwui-switch-btn').each(function() {

$(this).bind("click", function() {

var btn = $(this).find("span");

var change = btn.attr("change");

btn.toggleClass('off');

if(btn.attr("class") == 'off') {

$(this).find("input").val("0");

btn.attr("change", btn.html());

btn.html(change);

} else {

$(this).find("input").val("1");

btn.attr("change", btn.html());

btn.html(change);

}

return false;

});

});

$("#submit").click(function() {

var form = $(this).parent()[0];

var inputs = form.getElementsByTagName('input');

var params = [];

$('#debuger').html('');

for (var i=0; i < inputs.length; i++) {

params.push(inputs[i].name+"="+inputs[i].value);

}

$.post("post.php", params.join("&")+"&temp="+Math.random(), function(data) {

$('#debuger').html(data);

});

return false;

});

});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值