gpt4 book ai didi

jquery - 为什么 TextArea 的更改事件未在我的 ASP.net 页面中触发

转载 作者:行者123 更新时间:2023-12-01 06:26:38 24 4
gpt4 key购买 nike

我的 asp.net 页面中有以下代码:

<asp:UpdatePanel runat="server" ClientIDMode="Static" ID="upTaskDetailRight" UpdateMode="Conditional">
<ContentTemplate>
<div style="width: 98%; padding-bottom: 10px;" class="brClear">
<div class="noteClass brClear">Notes</div>
<div style="width: 98%; height: 120px;">
<textarea id="taskNotes" runat="server" class="taskNotes" style="width: 100%; height: 100%; scrollbar-base-color: #A0A0A0; scrollbar-base-color: #A0A0A0; scrollbar-3dlight-color: #A0A0A0; scrollbar-highlight-color: #A0A0A0; scrollbar-track-color: #EBEBEB; scrollbar-arrow-color: #FFFFFF; scrollbar-shadow-color: #A0A0A0; scrollbar-darkshadow-color: #A0A0A0;"></textarea>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnComplete" EventName="Click" />
</Triggers>
</asp:UpdatePanel>

翻译成这个 HTML 源代码:

<div id="upTaskDetailRight">
<div style="width: 98%; padding-bottom: 10px;" class="brClear">
<div class="noteClass brClear">Notes</div>
<div style="width: 98%; height: 120px;">
<textarea name="ctl00$ContentMain$taskNotes" id="ContentMain_taskNotes" class="taskNotes" style="width: 100%; height: 100%; scrollbar-base-color: #A0A0A0; scrollbar-base-color: #A0A0A0; scrollbar-3dlight-color: #A0A0A0; scrollbar-highlight-color: #A0A0A0; scrollbar-track-color: #EBEBEB; scrollbar-arrow-color: #FFFFFF; scrollbar-shadow-color: #A0A0A0; scrollbar-darkshadow-color: #A0A0A0;"></textarea>
</div>
</div>
</div>

我有以下 JQuery:

$(function () {
$("body").on('change', "#ContentMain_taskNotes", function (e) {
alert("changing");
});
});

我想要它做的是,每次我对 TextArea 进行任何更改时,它都应该向我显示 更改 警报,但当我在 TextArea 中键入或删除任何内容时,什么也没有发生.

我做错了什么以及如何解决它?

最佳答案

改为绑定(bind)input propertychange。这将在每次更改时发出警报。 change 事件仅在离开文本区域时才会触发。

$(function () {
$("body").on('input propertychange', "#ContentMain_taskNotes", function (e) {
alert("changing");
});
});

JSFiddle .

关于jquery - 为什么 TextArea 的更改事件未在我的 ASP.net 页面中触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25555847/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com