Home > Web Front-end > JS Tutorial > body text

JavaScript method to add double actions to buttons_javascript skills

WBOY
Release: 2016-05-16 15:45:11
Original
1212 people have browsed it

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>
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template