JavaScript基本入门语法集合第1/3页
时间:2022-11-08 09:50:51|栏目:JavaScript代码|点击: 次
创建脚本块
<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="/”youname.js"”></script>
注释脚本
// 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”);
<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="/”youname.js"”></script>
注释脚本
// 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”);
上一篇:js完全解析url和拼接
栏 目:JavaScript代码
下一篇:javascript验证只能输入数字和一个小数点示例
本文地址:http://www.codeinn.net/misctech/218498.html