課程
/前端開發(fā)
/jQuery
/jQuery基礎(chǔ)課程
大家?guī)臀铱纯茨睦锍鲥e(cuò)了
2016-03-24
源自:jQuery基礎(chǔ)課程 6-4
正在回答
toggle()本來有點(diǎn)擊的功能,用法如下:
1、$("#btntest").bind("click", function () {??????????????????? $("div").toggle()????? })
2、$("#btntest").toggle(??????????????????? function(){??????????????????????? $("div").hide();??????????????????? },??????????????????? function(){?????????????????????? $("div").show();????? })
但是你的用法把兩種結(jié)合在一起了,這是不合法的。
toggle()不是本來就能顯示和隱藏么
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
? ? <head>
? ? ? ? <title>toggle()方法綁定多個(gè)函數(shù)</title>
? ? ? ? <script src="http://libs.baidu.com/jquery/1.8.2/jquery.js" type="text/javascript"></script>
? ? ? ? <link href="style.css" rel="stylesheet" type="text/css" />
? ? </head>
? ? <body>
? ? ? ? <h3>toggle()方法綁定多個(gè)函數(shù)</h3>
? ? ? ? <input id="btntest" type="button" value="點(diǎn)一下我" />
? ? ? ? <div>我是動(dòng)態(tài)顯示的</div>
? ? ? ??
? ? ? ? <script type="text/javascript">
? ? ? ? ? ? $(function () {
? ? ? ? ? ? ? ? // 注釋掉這行 $("#btntest").bind("click", function () {
? ? ? ? ? ? ? ? ? ? $("#btntest").toggle(
????????????????????function(){
? ? ? ? ? ? ? ? ? ? ? ? $(this).hide();
? ? ? ? ? ? ? ? ? ? },function(){
? ? ? ? ? ? ? ? ? ? ? ?$(this).show();
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ?// })
? ? ? ? ? ? });
? ? ? ? </script>
? ? </body>
</html>
舉報(bào)
加入課程學(xué)習(xí),有效提高前端開發(fā)速度
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-04-03
toggle()本來有點(diǎn)擊的功能,用法如下:
1、$("#btntest").bind("click", function () {
??????????????????? $("div").toggle()
????? })
2、$("#btntest").toggle(
??????????????????? function(){
??????????????????????? $("div").hide();
??????????????????? },
??????????????????? function(){
?????????????????????? $("div").show();
????? })
但是你的用法把兩種結(jié)合在一起了,這是不合法的。
2016-03-24
toggle()不是本來就能顯示和隱藏么
2016-03-24
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
? ? <head>
? ? ? ? <title>toggle()方法綁定多個(gè)函數(shù)</title>
? ? ? ? <script src="http://libs.baidu.com/jquery/1.8.2/jquery.js" type="text/javascript"></script>
? ? ? ? <link href="style.css" rel="stylesheet" type="text/css" />
? ? </head>
? ? <body>
? ? ? ? <h3>toggle()方法綁定多個(gè)函數(shù)</h3>
? ? ? ? <input id="btntest" type="button" value="點(diǎn)一下我" />
? ? ? ? <div>我是動(dòng)態(tài)顯示的</div>
? ? ? ??
? ? ? ? <script type="text/javascript">
? ? ? ? ? ? $(function () {
? ? ? ? ? ? ? ? // 注釋掉這行 $("#btntest").bind("click", function () {
? ? ? ? ? ? ? ? ? ? $("#btntest").toggle(
????????????????????function(){
? ? ? ? ? ? ? ? ? ? ? ? $(this).hide();
? ? ? ? ? ? ? ? ? ? },function(){
? ? ? ? ? ? ? ? ? ? ? ?$(this).show();
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ?// })
? ? ? ? ? ? });
? ? ? ? </script>
? ? </body>
</html>