第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

關(guān)于for循環(huán)中進(jìn)行a標(biāo)簽的點(diǎn)擊事件

關(guān)于for循環(huán)中進(jìn)行a標(biāo)簽的點(diǎn)擊事件

青春有我 2018-12-21 19:15:40
代碼如下: for循環(huán)中有兩個(gè)可以下載文件的a標(biāo)簽,現(xiàn)在只能下載最后一個(gè)a標(biāo)簽的文件......for(var v = 0; v < $("div#downFile a").length; v++){    $("div#downFile a")[v].click();}
查看完整描述

1 回答

?
湖上湖

TA貢獻(xiàn)2003條經(jīng)驗(yàn) 獲得超2個(gè)贊

你還能下載一個(gè)也是夠給力的。

  • 你看你的代碼,你是已經(jīng)處在使用jquery對(duì)象的函數(shù)里面,有沒(méi)有想過(guò),你執(zhí)行for的時(shí)候,你拿到的都是什么。

  • You can't use 'macro parameter character #' in math mode("div#downFile a")[v]這個(gè)已經(jīng)是DOM對(duì)象了,不是jquery對(duì)象了。

  • (("div#downFile a")[v])這個(gè)才是能夠用.click()操作的jquery對(duì)象

  • jquery封裝的東西和原生的DOM或者JS都是有區(qū)別的,這也是他敢說(shuō)Write less, do more的魅力啦。

console.log($("div#downFile a")); // 數(shù)組

for(var v = 0; v < $("div#downFile a").length; v++){

    console.log('-----------------');

    

    console.log($("div#downFile a")[v]); // DOM對(duì)象

    console.log($($("div#downFile a")[v])); // jquery對(duì)象

    

    $("div#downFile a")[v].click(function(){

        console.log($(this)); // 不反應(yīng)

    });

    

    $($("div#downFile a")[v]).click(function(){

        console.log($(this)); // 輸出當(dāng)前點(diǎn)擊對(duì)象

    });

}


查看完整回答
反對(duì) 回復(fù) 2019-01-02
  • 1 回答
  • 0 關(guān)注
  • 964 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)