此代码适用于Chrome,Safari,Opera,firefox和IE(感谢条件评论黑客,因为IE将隐藏的表单元素与其他浏览器区别对待).如果您提交封闭表单,则会在生成的表单提交中获得普通的HTML复选框行为.
<!DOCTYPE HTML PUBliC "-//W3C//DTD xhtml 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd"> <HTML xmlns="http://www.w3.org/1999/xhtml"> <head> <Title>jquery Toggle @R_404_5554@ </Title> <script type="text/JavaScript" src="http://AJAX.GoogleAPIs.com/AJAX/libs/jquery/1.3.2/jquery.min.Js"></script> <style type="text/CSS"> /* Style the label so it looks like a @R_404_5554@ */ label { border: 2px outset #cccccc; background-color: #cccccc; position: relative; z-index: 3; padding: 4px; } /* CSS to make the checkBox disappear (but remain functional) */ label input { position: absolute; visibility: hIDden; } </style> <!--[if IE]> /* Conditional styles applIEd in IE only to work around cross-browser BUGs */ <style> label input#myCheckBox { visibility: visible; z-index: 2; } </style> <![endif]--> <script type="text/JavaScript"> $(function() { $("#toggleCheckBox").click(function() { $(this).closest("label").CSS({ borderStyle: this.checked ? 'inset' : 'outset' }); }); }); </script> </head> <body> <form action="http://www.w3schools.com/HTML/HTML_form_action.asp" method="get"> <label for="toggleCheckBox"> <input type="checkBox" name="toggled" ID="toggleCheckBox" value="1" /> Toggled?</label> <input type="@R_404_5555@" name="verb" value="@R_404_5555@ Form" /> </form> </body> </HTML>总结
以上是内存溢出为你收集整理的HTML切换按钮全部内容,希望文章能够帮你解决HTML切换按钮所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)