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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

jQuery attr('checked','checked')僅工作一次

jQuery attr('checked','checked')僅工作一次

我在查找以下jquery / checkbox行為的原因時遇到問題。$( this.obj + ' table.sgrid-content > thead > tr > th > input.select_all' ).on( 'click' , {grid:this} , function(event){var grid = event.data.grid;if( $(this).is(':checked') ){    $( grid.obj + ' table.sgrid-content > tbody > tr > td > input.select ' ).attr('checked','checked');    $( grid.obj + ' .sgrid-content > tbody > tr > td > input.select ' ).parents('tr').addClass('ui-state-highlight');} else {    $( grid.obj + ' table.sgrid-content > tbody > tr > td > input.select ' ).removeAttr('checked');    $( grid.obj + ' table.sgrid-content > tbody > tr > td > input.select ' ).parents('tr').removeClass('ui-state-highlight');}});該代碼旨在按以下方式工作:-單擊input.select_all觸發(fā)事件-如果選中了input.select_all:將選中的屬性添加到table.sgrid-content中標(biāo)記為.select的所有復(fù)選框-如果未選中:則刪除“ '屬性來自所有input.select項(xiàng)。另一個簡單的網(wǎng)格功能。而且有效。奇怪的是,它只能運(yùn)行一次。我的意思是,您可以選擇所有復(fù)選框,然后取消選擇它們。完成該操作后,“全選”功能將停止工作。另一個奇怪的事情是,當(dāng)我用螢火蟲檢查dom元素時,它們?nèi)慷甲兂闪藨?yīng)該被選中的“ checked”屬性,但是它們的顯示和行為卻未被選中。選擇器可以正常工作。添加/刪除ui-state-highlight的代碼部分一直有效。explenation的字: 網(wǎng)格 -是我通過得到grid.obj(一ceratain DIV的基本ID)的對象請給我您的意見。
查看完整描述

3 回答

?
湖上湖

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

使用prop('checked',true / false)代替removeAttr


$('input[name=foo]').prop('checked', true);

$('input[name=foo]').prop('checked', false);


查看完整回答
反對 回復(fù) 2019-12-04
?
倚天杖

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個贊

使用.prop('checked',true) and .prop('checked',false)代替.attr('checked','checked') or .removeAttr?,F(xiàn)在,jQuery中已棄用了用于操作檢查/選定狀態(tài)的attr 

查看完整回答
反對 回復(fù) 2019-12-04
?
躍然一笑

TA貢獻(xiàn)1826條經(jīng)驗(yàn) 獲得超6個贊

您可以更改屬性,并且如果該元素保持不變,也將更改屬性。元素離開此初始狀態(tài)后,更改屬性不再影響該屬性。確切的行為可能因?yàn)g覽器而異。


Instead of .attr('checked', 'cheked') use .prop('checked', true)


查看完整回答
反對 回復(fù) 2019-12-04
  • 3 回答
  • 0 關(guān)注
  • 540 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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