函数可以在响应事件中被调用,还可以在连接中被调用,在<a>标签中href标记中使用javascript:关键字 调用函数,当用户点击这个链接时,相关函数将被执行。

具体代码如下:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" language="javascript">
        function test() {alert("text !");}
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <a href="javascript:test();">test</a>
    </form>
</body>
</html>

相关文章:

  • 2021-11-10
  • 2021-08-03
  • 2022-12-23
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-04-28
  • 2021-09-28
  • 2022-12-23
  • 2022-12-23
  • 2021-06-02
  • 2021-10-16
  • 2022-02-19
相关资源
相似解决方案