为了账号安全,请及时绑定邮箱和手机立即绑定

JavaScript入门篇

难度入门
时长 1小时35分
学习人数
综合评分9.57
5509人评价 查看评价
9.8 内容实用
9.5 简洁易懂
9.4 逻辑清晰
<script type="text/javascript">
var mychar= document.getElementById("con");
mychar.style.color="red";
mychar.style.backgroundColor="#ccc";
mychar.style.width="300px";

</script>
function openwindow(){
var mymessage;
message=prompt("新窗口打开网站")
if(mymessage==true)
{window.open('http://www.imooc.com','_blank','width=400,height=500,menubar=no,toolbar=no, status=no,scrollbars=yes')}
else
{null}
}
function add(){
var p1 = document.getElementById("p1");
p1.className="one";
}
function modify(){
var p2 = document.getElementById("p2");
p2.className="two";
}
function hidetext()
{
var mychar = document.getElementById("con");
mychar.style.display="none";
}
function showtext()
{
var mychar = document.getElementById("con");
mychar.style.display="block";
}
var mychar=document.getElementById("con");
mychar.style.color="red";
mychar.style.backgroundColor="#CCC";
mychar.style.width="300px";
break;
case 1: tdiv.style.width='300px';
tdiv.style.height='300px';
break;
case 2:tdiv.style.display='none';
break;
case 3:tdiv.style.display='block';
break;
case 4:var x=confirm("are you sure quxiao");
if(x){
tdiv.removeAttribute('style');}
break;
}}}}
window.onload =function(){
var tdiv=document.getElementById('txt');
var bt=document.getElementsByTagName('input');
for(var i=0;i<bt.length;i++)
{
bt[i].index=i;
bt[i].onclick=function (){

switch (this.index){
case 0:
tdiv.style.color='red';
tdiv.style.backgroundColor='yellow';
函数必须声明function 否则是没办法调用的
<script type="text/javascript">
function Wopen(){
window.open('http://www.imooc.com','_blank','width=600','height=400','top=100','left=0')
}
</script>
</head>
<body>
<input name="button" type="button" onClick="Wopen()" value="点击我,打开新窗口!" / >

最赞回答 / Alyssa_Lee
相对路径例如你的script.js文件是放在一个叫js的文件夹里,js文件夹跟html文件在同一级目录,那么你的script.js的路径就可以写成src="js/script.js"
function openWindow(){
var conf=confirm('new window?');// 新窗口打开时弹出确认框,是否打开
if (conf){
var addr= prompt('addr ?','http://www.imooc.com/');// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
window.open(addr,'haha','width=400,height=500,menubar=no,toolbar=no');}
}
mychar.style.color="red";
mychar.style.backgroundColor="#CCC";
mychar.style.width="300px";
课程须知
该课程是针对新手的一个简单基础的课程,让您快速了解JS,通过一些简单的代码编写体会JS。如果您已经对JS有所了解,可以跳过本课程,学习JS进阶课程,进一步学习JS相应的基础知识。学习本课程,希望您至少具备HTML/CSS基础知识,认识常用的标签。
老师告诉你能学到什么?
1. 理解JavaScript基础语法; 2. 掌握常用语句的使用方法; 3. 学会如何获取DOM元素及进行简单操作。

微信扫码,参与3人拼团

意见反馈 帮助中心 APP下载
官方微信
友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消