toggle()-----显示隐藏
toggleClass-------添加类或者删除类
<!DOCTYPE html><html lang="en"><head> ???<meta charset="UTF-8"> ???<title>Title</title> ???<script src="jquery-1.11.1.js"></script> ???<style> ???????div { ???????????width: 100px; ???????????height: 100px; ???????????border: 1px solid #ccc; ???????} ???????.box1 { ???????????margin-right: 10px; ???????} ???????.show { ???????????background-color: red; ???????} ???</style> ???<script src="jquery-1.11.1.js"></script> ???<script> ???????$(function () { ???????????$("button").click(function () { ???????????????$(".box1").toggleClass("show"); ???????????}); ???????}); ???</script></head><body><button>切换</button><div class="box1"></div></body></html>
jQuery——切换toggle
原文地址:http://www.cnblogs.com/wuqiuxue/p/8032206.html