zoukankan      html  css  js  c++  java
  • javascript 基础

    0. js 与 html 的关系

    • .js是脚本,以文件的形式存在

      // test.js
      function sayHello() {
          document.write("hello javascript");
      }
      sayHello();
    • .html是页面.

      <script language="JavaScript" src="test.js"></script>
    • html 里面可以包含 js 脚本,但是 js 里面不能包含html页面

    1. 正则

    var str = "This is a text string";
    var reg = new RegExp("this", "i");
        // var reg = /this/i;  // 第一个参数为待匹配的模式,第二个参数为匹配时的参数选项;
    console.log(str.match(reg));

    2. document

    html 中嵌入的 js 代码,document 是类 HTMLDocument 的实例化对象,代表当前 html 文档。

    function sendlog(msg){
        document.getElementById("msgid").innerHTML = msg;
    }

    此函数的作用正在于:你的页面上有一个id为”msgid”的东西,可能是<div></div>,也可能是<span></span><td></td>。。。等一切可以在里面显示文字的html元素。这句话的意思就是把这个元素里面的文字换成传递过来的msg

  • 相关阅读:
    STL Allocator
    Several NeedToKnow(assert/stdin/stdout/CString/Standard C++ Library)
    VS Project Property Sheet
    进度总结(3)
    进度总结(2)
    进度总结(4)
    进度总结(7)
    进度总结(1)
    进度总结(5)
    进度总结(6)
  • 原文地址:https://www.cnblogs.com/mtcnn/p/9421089.html
Copyright © 2011-2022 走看看