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

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

將 JS 函數(shù)轉(zhuǎn)換為 jQuery

將 JS 函數(shù)轉(zhuǎn)換為 jQuery

慕標(biāo)琳琳 2022-05-14 13:49:48
這個(gè)JavaScript函數(shù)如何function reset() {    var customSelect = document.getElementsByClassName("custom-select")[0];    var select = customSelect.getElementsByTagName("select")[0];    var selected = customSelect.getElementsByClassName("select-selected")[0];    var selectedItem = customSelect.getElementsByClassName('same-as-selected')[0];    select.selectedIndex = 0;    selected.innerHTML = select.options[select.selectedIndex].innerHTML;    selectedItem.classList.remove('same-as-selected');}可以轉(zhuǎn)換成jQuery函數(shù)嗎?我試過(guò)這樣的第一個(gè)變量:  var customSelect = document.getElementsByClassName("custom-select")[0];  var jqcustomSelect = $(".custom-select:eq(0)").html();  console.log(customSelect + "  JQ: " + jqcustomSelect);但我對(duì)輸出感到困惑:customSelect = [object HTMLDivElement]盡管jqcustomSelect = html code1)如何轉(zhuǎn)換此功能?2)為什么customSelect輸出[object HTMLDivElement],而de輸出html代碼?
查看完整描述

1 回答

?
天涯盡頭無(wú)女友

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

你的 JQuery 函數(shù)應(yīng)該是這樣的


function reset(){

    var customSelect = $('.custom-select');

    var select = customSelect.find('select');

    select.prop('selectedIndex', 0);

    customSelect.find('.select-selected').html(select.find('option:selected').html());

    customSelect.find('.same-as-selected').removeClass('same-as-selected');

}

試試這個(gè),但沒(méi)有你的源代碼我不容易測(cè)試它


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

添加回答

舉報(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)