首页 > 代码库 > javascript第七1节课
javascript第七1节课
window.open("http://www.baidu.com","_blank","width=300, height=200");
进入百度。
<script type="text/javascript">
var content = "abc";
console.log( content.replace("b", "q") );
</script>
把b转换成q。
<script type="text/javascript">
var arr = ["orange", "mango", "banana", "sugar", "tea"];
console.log(arr);
arr.splice(2, 0, "fish");
2是第二个0是删除0个
document.write(arr);
document.write("<br/>");
出结果(orange,mango,fish,banana,sugar,tea)
arr.splice(5, 1);
5是第五个1是删除1个
document.write(arr);
出结果(orange,mango,fish,banana,sugar)
</script>
<script type="text/javascript">
var username = "a123456789";
//设置只能输入多小个数字
if( username.length > 7 ){
alert("请输入正确的用户名...");
}
</script>
<script type="text/javascript">
var title = "出席二十国集团领导人杭州峰会系列活动纪实";
document.write( title.substr(0, 10) + "...");
看到1到10个字其余的用"..."表示。
</script>
<script type="text/javascript">
var result = confirm("你确认删除?");
console.log(result);
if( result ){
alert("正在删除中...");
}else{
alert("你取消了删除");
}
</script>
<script type="text/javascript">
var username = "a123456";
console.log(username.charAt(0));
for(var i = 0; i < username.length; i++) {
document.write(‘<span class="font‘ + i + ‘">‘ + username.charAt(i) + "</span>");
}
</script>
javascript第七1节课