gpt4 book ai didi

javascript - '$(<%= DDL.ID %>) & $(' <%=​​ DDL.ID %>'之间的差异)

转载 作者:行者123 更新时间:2023-11-30 07:00:59 26 4
gpt4 key购买 nike

我试图将一个事件绑定(bind)到下拉列表,因为昨天没有任何帮助去 JavaScript 聊天室,没有人能够找到解决我的问题的方法,但后来我以某种方式尝试绑定(bind)我的下拉列表,如下所示

$('<%= ddl.ID %>').bind('change',myfunction);

$(<%= ddl.ID %>).bind('change',myfunction);

它开始工作了,知道吗?

编辑

抱歉,它不能在 IE 上运行 :(

最佳答案

jQuery 使用类似 CSS 选择器 的语法。

对于ID Selector,它需要以#符号作为前缀。例如,$('#DOMElementId')

检查 jQuery Selector list

在你的情况下正确的应该是

$('#<%= ddl.ID %>').bind('change',myfunction) // if you have no master page or 
//ClientIDMode="static"

$('#<%= ddl.ClientID %>').bind('change',myfunction)

关于javascript - '$(<%= DDL.ID %>) & $(' <%=​​ DDL.ID %>'之间的差异),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12402823/

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