创建脚本块
<script language=”JavaScript”>
JavaScript code goes here
</script>
隐藏脚本代码

<script language=”JavaScript”>
<!--
document.write(“Hello”);
// -->
</script>

浏览器不支持的时候显示

<noscript>
Hello to the non-JavaScript browser.
</noscript>

链接外部脚本文件

<script language=”JavaScript” src="/UploadFiles/2021-04-02/”youname.js">
注释脚本

// This is a comment
document.write(“Hello”); // This is a comment
/*
All of this
is a comment
*/

输出到浏览器

document.write(“<strong>输出内容</strong>”);

定义变量

var myVariable = “some value”;

字符串相加

var myString = “String1” + “String2”;

字符串搜索

<script language=”JavaScript”>
<!--
var myVariable = “Hello there”;
var therePlace = myVariable.search(“there”);
document.write(therePlace);
// -->
</script>

字符串替换

thisVar.replace(“Monday”,”Friday”);
123下一页阅读全文
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!