zoukankan      html  css  js  c++  java
  • 调用JS的方法

    触发javascript写的方法:

    1、在button的click直接写JS语句调用

        <button type="button" onclick="alert('Welcome!')">点击这里</button>

    2、在button的click绑定js方法,点击时会调用

    复制代码
    <script>
    function myFunction()
    {
    x=document.getElementById("demo");  // 找到元素
    x.innerHTML="Hello JavaScript!";    // 改变内容
    }
    </script>
    <button type="button" onclick="myFunction()">点击这里</button>
    复制代码

    3 表单的onsumit和onclick都可以绑定js方法,提交前调用

    JS代码验证信息填写:

    <script type="text/javascript">
          function checkInput(){
              var str1 = document.getElementById("login-username").value;
              if(str1==""){
                  alert("请将信息填写完整!");
                  return false;
              }
                  return true;
          }
      </script>
    <s:form action="" onsubmit="checkInput();">
    
    <s:textfield name="u_name"  id="login-username" label="用户名:" ></s:textfield>
    <s:submit value="注册" onclick="checkInput();"></s:submit>
    </s:form>

    注意,如果方法有返回bool值,要return checkInput();这样调用才会起作用。

    Done!

  • 相关阅读:
    Discovery Scanning
    Openvas
    Common Vulnerability Scoring System CVSS
    NIagara Workbench ( 温度控制)
    Nikto and whatweb
    Jace Config
    Active information gathering-services enumeration
    Intsall The Nessus in you kali linux
    Source Code Review
    Niagara workbench (Basic )
  • 原文地址:https://www.cnblogs.com/xingyyy/p/3903649.html
Copyright © 2011-2022 走看看