仿iPhone开关式按钮(jQuery+CSS3)
004 | < meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" /> |
005 | < meta name = "author" content = "pandao QQ:272383090" /> |
006 | < title >仿iPhone开关式按钮(jQuery+CSS3)</ title > |
007 | < style type = "text/css" > |
008 | *{margin:0;padding:0;} |
009 | body{font-size:14px;color:#444;font-family:"微软雅黑",Arial;background:#fff;padding:50px;} |
010 | a{color:#444;text-decoration: none;} |
011 | a:hover{color:#065BC2;text-decoration: none;} |
013 | img{border:none;vertical-align: middle;} |
022 | border:1px solid #2E58C1; |
026 | .mwui-switch-btn span{ |
030 | padding:4px 5px 2px 5px; |
032 | filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#f6f6f6,endColorstr=#eeeeee,grandientType=1); |
033 | background:-webkit-gradient(linear, 0 0, 0 100%, from(#f6f6f6), to(#eeeeee)); |
034 | background:-moz-linear-gradient(top, #f6f6f6, #eeeeee); |
040 | .mwui-switch-btn:hover span{ |
043 | .mwui-switch-btn span.off{float:right;} |
044 | input[type='submit']{padding:5px 10px;cursor: pointer;} |
049 | 显示图标1:< button class = "mwui-switch-btn" >< span change = "开" class = "off" >关</ span >< input type = "hidden" name = "show_icon" value = "0" /></ button > |
050 | 显示顶栏1:< button class = "mwui-switch-btn" >< span change = "关" >开</ span >< input type = "hidden" name = "open_topbar" value = "1" /></ button > |
052 | 显示图标2:< button class = "mwui-switch-btn" >< span change = "OFF" >ON</ span >< input type = "hidden" name = "show_icon2" value = "1" /></ button > |
053 | 显示顶栏2:< button class = "mwui-switch-btn" >< span change = "ON" class = "off" >OFF</ span >< input type = "hidden" name = "open_topbar2" value = "0" /></ button > |
055 | < input type = "submit" id = "submit" value = "提交" /> |
057 | < div id = "debuger" ></ div > |
058 | < script type = "text/javascript" src = "http://code.jquery.com/jquery-1.6.4.min.js" ></ script > |
059 | < script type = "text/javascript" > |
061 | $('.mwui-switch-btn').each(function() { |
062 | $(this).bind("click", function() { |
063 | var btn = $(this).find("span"); |
064 | var change = btn.attr("change"); |
065 | btn.toggleClass('off'); |
067 | if(btn.attr("class") == 'off') { |
068 | $(this).find("input").val("0"); |
069 | btn.attr("change", btn.html()); |
072 | $(this).find("input").val("1"); |
073 | btn.attr("change", btn.html()); |
081 | $("#submit").click(function() { |
082 | var form = $(this).parent()[0]; |
083 | var inputs = form.getElementsByTagName('input'); |
085 | $('#debuger').html(''); |
087 | for (var i=0; i < inputs.length ; i++) { |
088 | params.push(inputs[i].name+"="+inputs[i].value); |
091 | $.post("post.php", params.join("&")+"&temp="+Math.random(), function(data) { |
092 | $('#debuger').html(data); |