toggle()方法
?<script type="text/javascript">
? ? ? ? ? ? $(function () {
? ? ? ? ? ? ? ? $("#btntest").bind("click", function () {
? ? ? ? ? ? ? ? ? ? $("div").toggle(
? ? ? ? ? ? ? ? ? ? ? ? function(){
? ? ? ? ? ? ? ? ? ? ? ? ? ? $(this).attr("display","none")
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? )
? ? ? ? ? ? ? ? })
? ? ? ? ? ? });
? ? ? ? </script>
上面代碼只寫了一句
?$("div").toggle(
? ? ? ? ? ? ? ? ? ? ? ? function(){
? ? ? ? ? ? ? ? ? ? ? ? ? ? $(this).attr("display","none")
? ? ? ? ? ? ? ? ? ? ? ? }
為什么就能實(shí)現(xiàn)效果 ? 綁定的單擊事件每次單機(jī)都觸發(fā)一次 ? 應(yīng)該點(diǎn)第一次開始就是none ?后面點(diǎn)擊不改變display 的值 ?可是右邊的實(shí)現(xiàn)確實(shí)成功的 ?為什么
2016-04-08
toggle的作用