zoukankan      html  css  js  c++  java
  • JS 之CLASS类应用

    <script type="text/javascript"> 
    function register(){ 
    this.check_username = function(){ 
    if(document.getElementById("username").value == ""){ 
    alert("用户名不能为空"); 


    this.check_password = function(){ 
    if(document.getElementById("password").value == ""){ 
    alert("用户名不能为空"); 



    new register().check_username(); //调用方法 
    </script> 
    上面的这种用的是方法类,大方法是register,里面定义的二个小方法,一个是对用户名的check,一个是对密码的check. 
    <script type="text/javascript"> 
    var register = { 
    check_username:function(){ 
    if(document.getElementById("username").value == ""){ 
    alert("用户名不能为空"); 

    }, 
    check_password:function(){ 
    if(document.getElementById("password").value == ""){ 
    alert("用户名不能为空"); 



    register.check_username(); //调用方法 
    </script> 
    个人觉得通过域,来对function进行管理,规划最简单明了。

  • 相关阅读:
    核心动画的使用
    核心动画的使用
    核心动画的使用
    异常上报功能Bugly简介
    核心动画的使用
    一种传统的程序模块化马甲包开发架构
    定时器、多线程
    核心动画
    Core Animation 核心动画
    核心动画的使用
  • 原文地址:https://www.cnblogs.com/leonkobe/p/4012077.html
Copyright © 2011-2022 走看看