[英]JavaScript called from Div onclick running button.click call
I have a Div onclick function that calls the JavaScript function below 我有一个Div onclick函数,该函数在下面调用JavaScript函数
function MonthViewDay(sDate){
var txtHidden = document.getElementById('<%=txtHidden.ClientID %>');
var btn_Hidden = document.getElementById('<%= btn_Hidden.ClientID %>');
if (txtHidden !== null) {
txtHidden.innerText = sDate;
} else{
alert("Control '<%=txtHidden.ClientID %>' not found.");
}
if (btn_Hidden !== null) {
btn_Hidden.click;
} else {
alert("Control '<%= btn_Hidden.ClientID %>' not found.");
}
}
The problem I am getting is that the btn_Hidden.click is not firing, but the txtHidden text is being update, but the btn_Hidden.click is not firing. 我遇到的问题是btn_Hidden.click没有启动,但是txtHidden文本正在更新,但是btn_Hidden.click没有启动。
As you can see from my sample, I have a 'test' in place to see if the btn control is found and it is, as far as I can see. 正如您从样本中看到的那样,据我所知,我有一个“测试”来检查是否找到了btn控件。
Troubleshooting steps I have taken are, 我已采取的故障排除步骤是
document.getElementById('<%= btn_Hidden.ClientID %>').click
instead of btn_Hidden.click, no help. document.getElementById('<%= btn_Hidden.ClientID %>').click
而不是btn_Hidden.click,没有帮助。 Please assist. 请协助。
Thank you in advance 先感谢您
Rhys 里斯
Click is a method not a field in javascript 点击是方法,而不是JavaScript中的字段
Simulate a mouse-click use .click()
; 使用
.click()
模拟鼠标单击;
In your code use 在您的代码中使用
btn_Hidden.click();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.