The example in this article describes how to add double actions to buttons using JavaScript. Share it with everyone for your reference. The details are as follows:
Here, JavaScript is used to add two actions to the button on the web page at the same time. One is to display text in the text box, and the other is to redirect to a certain URL. In the past, the button jump was single, and this one is jumping again. The action of assigning text to the text box has been added during the transfer. Once you understand the principle, you can use it flexibly.
The screenshot of the running effect is as follows:
The online demo address is as follows:
http://demo.jb51.net/js/2015/js-button-two-action-codes/
The specific code is as follows:
<title>JavaScript给按钮加上双重动作</title> <script language=JavaScript> function jdk1x() { var num1 = document.x.jdk.value; if(num1 == 'three') { document.x.jdk.value = document.x.jdk.value } else { document.x.jdk.value = "脚本之家欢迎您!" } location="http://www.jb51.net/" } </script> <form name=x> <input type=button value="脚本之家" onClick="jdk1x()"><br> <input type=text name=jdk width="300" onChange="document.x.jdk.value=''; return true"> </form>
I hope this article will be helpful to everyone’s JavaScript programming design.