如何使用href onclick调用Javascript函数? [英] how to call Javascript function using href onclick?
本文介绍了如何使用href onclick调用Javascript函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的aspx有以下编码:
Hi, my aspx has the following codings :
<script type="text/javascript">
function Visible() {
panel = document.getElementsById("NewUserDIV");
panel.style.visibility = "visible";
}
.
.
.
.
.
<tr>
<td>
New User <a href="#" önclick="Visible();">Click Here</a>
</td>
</tr>
.
.
.
<div id="NewUserDIV" style="visibility : hidden;">
<asp:panel ID="NewUserPanel" runat="server" >
Hi New User
</asp:panel>
</div>
但是当我点击href链接时在我的页面中没有发生任何事情,只是符号#附加了URL ...但是如何调用JavaScript函数使DIV可见?
在预先感谢:)
祝你有美好的一天:)
But when I click the href link, nothing get happened in my page, just the symbol # is getting appended with the URL ... but how should I call the JavaScript function to make the DIV visible ?
Thanks in Advance :)
Have a great day all :)
推荐答案
原因是一个小错字:你写了getElement s ById
,但它应该是getElementById
,没有s
The reason is a small typo: you wrotegetElementsById
, but it should begetElementById
, without thes
function Visible() {
panel = document.getElementById("NewUserDIV");
panel.style.visibility = "visible";
}
这篇关于如何使用href onclick调用Javascript函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文