簡體   English   中英

jQuery 和復選框,我看不到更改

[英]jQuery and checkboxes, i can't see the changes

我在 ASP 項目轉發器中有很多復選框:

<asp:Repeater ID="rpPostes" runat="server" DataSource="<%# this.ItemsPostesBudgetaires %>">

在中繼器內的某個地方,一個復選框描述為:

<asp:CheckBox runat="server" Class="chk" ID="chkPieceJust" Text="Recues" Visible="<%#  Mode.HasFlag(ModeType._BoutonsApprobation)  %>" Enabled="<%# CheckBoxDispo() %>" Checked="<%# CheckBoxChecked(Container.DataItem as Transaction) %>" />

最后,一個按鈕可以將每個復選框變為 true :

<input id="chkAllPieceJust" type="button" value="Toutes Pièces Justificatives Recues" onclick="CTCC.Transactions.PieceRecuClick(this);" />

最后這是我的 jQuery 函數:

CTCC.Transactions.PieceRecuClick = function (source) {

$('.chk').attr('checked', true);

}

單擊按鈕后會發生那種 html 輸出:

<span class="chk" checked="checked"><input ... blablabla

但沒有任何反應,根本沒有選中復選框......

我不知道我還需要什么......

Checkbox控件的CssClass屬性實際上將該類應用於包裝復選框本身的span元素。 您可以通過在代碼隱藏中分配類直接將類應用於復選框元素,如下所示:

MyCheckBox.InputAttributes["class"] = "chk";

或者修改你的jquery來查找.chk元素的輸入子元素,像這樣

$(".chk input[type='checkbox']").prop('checked', true);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM