zoukankan      html  css  js  c++  java
  • Javascript 试题汇集

    1.点击一个按钮,打开一个页面的几种方法:

       <input type="button" value="location" onclick="window.location='index1.html'">
        <input type="button" value="assign" onclick="location.assign('index1.html')">
        <input type="button" value="open" onclick="window.open('index1.html')">
        <form target="_blank" action="index1.html">
            <input type="submit" value="new">
        </form>

    下面两种是打开一个新的页面。

    2.实现检索当前页面中的表单元素中的所有文本框

    要考虑到页面中不止一个form表单

    function clearAllText(){
        for(var i=0;i<document.forms.length;i++){
            for(var j=0;j<document.forms[i].length;j++){
                if(document.forms[i].elements[j].type=="text")
                    document.forms[i].elements[j].value="";        
            }
        }
    }

    3.undefined ullfalse 在是希望值是布尔类型的情况下

        var a="undefined";
        var b="false";
        var c="null";
        var d=undefined;
        var e=false;
        var f=null;
        var g="";

    解析:a,b,c都是字符串,只要字符串非空,则其布尔类型的值都是true。

       d,e,f,g 在其布尔类型的值都是false。

  • 相关阅读:
    Redis源码阅读笔记(2)——字典(Map)实现原理
    Partition List ——LeetCode
    docker format (golang template)
    markdown 换行
    pecan快速教程
    nvdimm
    k8s device plugin
    linux 文件同步
    复制MIFARE Classic卡
    install docker swarm on centos
  • 原文地址:https://www.cnblogs.com/yanyangbyou/p/3990550.html
Copyright © 2011-2022 走看看