• js常用方法(。。。。不完整)


    lastIndexOf();
    substring();
    split();
    slice();
    splice();
    var s="http://www.baidu.com";
    var i= s.lastIndexOf("."); //16
    var unit= s.substring(i); //.com
    var url= s.substring(0,i);  //http://www.baidu
       addLoadEvent(func1);
       addLoadEvent(func2);
       function addLoadEvent(func){
           var oldonload=window.onload;
           if(typeof window.onload!='function'){
               window.onload=func;
           }else{
               window.onload=function() {
                   oldonload();
                   func();
               }
           }
       };
        function func1(){
            alert("text1");
        };
        function func2(){
            alert("text2");
        };
    <ul id="imagegallery">
            <li><a href="images/ads/1.jpg" title="广告1">广告1</a></li>
            <li><a href="images/ads/2.jpg" title="广告2">广告2</a></li>
            <li><a href="images/ads/3.jpg" title="广告3">广告3</a></li>
            <li><a href="images/ads/4.jpg" title="广告4">广告4</a></li>
        </ul>
        <p id="description">Choose an image</p>
        <img id="placeholder" src="images/ads/adindex.gif" alt="my image gallery">
    window.onload = prepareGallery();
        function prepareGallery() {
            if (!document.getElementsByTagName) return false;
            if (!document.getElementById) return false;
            if (!document.getElementById("imagegallery")) return false;
            var gallery = document.getElementById("imagegallery");
            var links = gallery.getElementsByTagName("a");
            for (var i = 0; i < links.length; i++) {
                links[i].onclick = function () {
                    return showPic(this) ? false : true;
                }
            }
        }
        function showPic(whichpic) {
            if (!document.getElementById("placeholder")) return false;
            var sourse = whichpic.getAttribute("href");
            var placeholder = document.getElementById("placeholder");
            if (placeholder.nodeName != "IMG") return false;
            placeholder.setAttribute("src", sourse);
            //
            if (document.getElementById("description")) {
                var text = whichpic.getAttribute("title") ? whichpic.getAttribute("title") : "";
                var description = document.getElementById("description");
                if (description.firstChild.nodeType == 3) {
                    description.firstChild.nodeValue = text;
                }
            }
            return true;
        }

  • 相关阅读:
    python3-while与if
    python3-while与continue
    python3-password在输入密码时隐藏密码
    input与字符串格式化
    for与break的用法
    bochs 2.6.8 常用命令集合
    关于8086中的jmp near ptr原理
    如何学习Python课程
    微信公众号去除密码安全提示
    模块的使用
  • 原文地址:https://www.cnblogs.com/zhaojieln/p/4314224.html
Copyright © 2020-2023  润新知