为了账号安全,请及时绑定邮箱和手机立即绑定
慕课网数字资源数据库体验端
JavaScript入门篇 _学习笔记_慕课网
为了账号安全,请及时绑定邮箱和手机立即绑定

JavaScript入门篇

慕课官方号 页面重构设计
难度入门
时长 1小时35分
  • 1.参数之间逗号及等号前后有空格,该字符串无效,只有删除空格才能正常运行。 2.运行结果考虑浏览器兼容问题。
    查看全部
  • open() 方法可以查找一个已经存在或者新建的浏览器窗口。 语法: window.open([URL], [窗口名称], [参数字符串]) 参数说明: URL:可选参数,在窗口中要显示网页的网址或路径。如果省略这个参数,或者它的值是空字符串,那么窗口就不显示任何文档。 窗口名称:可选参数,被打开窗口的名称。 1.该名称由字母、数字和下划线字符组成。 2."_top"、"_blank"、"_selft"具有特殊意义的名称。 _blank:在新窗口显示目标网页 _self:在当前窗口显示目标网页 _top:框架网页中在上部窗口中显示目标网页 3.相同 name 的窗口只能创建一个,要想创建多个窗口则 name 不能相同。 4.name 不能包含有空格。 参数字符串:可选参数,设置窗口参数,各参数用逗号隔开。 参数表: 例如:打开http://www.imooc.com网站,大小为300px * 200px,无菜单,无工具栏,无状态栏,有滚动条窗口: <script type="text/javascript"> window.open('http://www.imooc.com','_blank','width=300,height=200,menubar=no,toolbar=no, status=no,scrollbars=yes') </script>
    查看全部
  • var txt=document.getElementById("txt"); var set={ changeColor:function(){ txt.style.color="red"; txt.style.backgroundColor="#ccc"; }, changeSize:function(){ txt.style.width="300px"; txt.style.height="300px"; }, objHide:function(){ txt.style.display="none"; }, objShow:function(){ txt.style.display="block"; }, offSet:function(){ var message=confirm("你确定要重置所有设置么?"); if(message==true){ txt.removeAttribute('style'); } } }
    查看全部
    0 采集 收起 来源:编程挑战

    2018-03-22

  • 1,统一声明变量; 2,函数的命名方式:changeColor,changeSize,hideText,showTest,resettext 3, mydiv.removeAttribute("style");
    查看全部
    0 采集 收起 来源:编程挑战

    2018-03-22

  • 取消样式(style)设置:document.getElementById("txt").removeAttribute("style");
    查看全部
    0 采集 收起 来源:编程挑战

    2018-03-22

  • className 属性设置或返回元素的class 属性。(理解:可以通过className来设置样式的,也可以获取classname名) 语法:object.className = classname 作用: 1,获取元素的class 属性 2,为网页内的某个元素指定一个css样式来更改该元素的外观
    查看全部
  • 网页中经常会看到显示和隐藏的效果,可通过display属性来设置。 语法:Object.style.display = value(取值:none,block) 注意:Object是获取的元素对象,如通过document.getElementById("id")获取的元素。
    查看全部
  • 笔记三: list-style-type listStyleType list-style-image listStyleImage list-style-position listStylePosition list-style listStyle white-space whiteSpace font font font-family fontFamily font-size fontSize font-style fontStyle font-variant fontVariant font-weight fontWeight letter-spacing letterSpacing line-break lineBreak line-height lineHeight text-align textAlign text-decoration textDecoration text-indent textIndent text-justify textJustify text-transform textTransform vertical-align verticalAlign (可能还有,自己积累下) 至于赋值,:是CSS赋值方式;JS的赋值方式是=。js用到:一般是三元运算符。 单双引号的区别不大,作用可以视作一样。
    查看全部
    1 采集 收起 来源:改变 HTML 样式

    2015-08-03

  • 笔记二: border-top-width borderTopWidth border-width borderWidth clear clear float floatStyle margin margin margin-bottom marginBottom margin-left marginLeft margin-right marginRight margin-top marginTop padding padding padding-bottom paddingBottom padding-left paddingLeft padding-right paddingRight padding-top paddingTop background background background-attachment backgroundAttachment background-color backgroundColor background-image backgroundImage background-position backgroundPosition background-repeat backgroundRepeat color color display display
    查看全部
    0 采集 收起 来源:改变 HTML 样式

    2015-08-03

  • 笔记一: 这里的代码:backgroundColor中的C一定大写的。(驼峰法命名) 应该区分一下js和css属性是不一样的。 fontSize是JS属性。fontsize是CSS属性。 CSS语法 (不区分大小写) JavaScript语法 (区分大小写) border border border-bottom borderBottom border-bottom-color borderBottomColor border-bottom-style borderBottomStyle border-bottom-width borderBottomWidth border-color borderColor border-left borderLeft border-left-color borderLeftColor border-left-style borderLeftStyle border-left-width borderLeftWidth border-right borderRight border-right-color borderRightColor border-right-style borderRightStyle border-right-width borderRightWidth border-style borderStyle border-top borderTop border-top-color borderTopColor border-top-style borderTopStyle
    查看全部
    1 采集 收起 来源:改变 HTML 样式

    2015-08-03

  • HTML DOM 允许 JavaScript 改变 HTML 元素的样式。 1,语法:Object.style.property=new style; 2,注意:Object是获取的元素对象,如通过document.getElementById("id")获取的元素。
    查看全部
    0 采集 收起 来源:改变 HTML 样式

    2018-03-22

  • 沉重的代价:一段代码无法得到想要的结果,耗费近半个小时的时间查找错误。 Uncaught SyntaxError: Unexpected token ILLEGAL 结果是末尾的“;”用了中文的。
    查看全部
    0 采集 收起 来源:改变 HTML 样式

    2015-08-03

  • innerHTML 属性用于获取或替换 HTML 元素的内容。 语法:Object.innerHTML 注意: 1.Object是获取的元素对象,如通过document.getElementById("ID")获取的元素。 2.注意书写,innerHTML区分大小写。
    查看全部
    0 采集 收起 来源:innerHTML 属性

    2018-03-22

  • 1,通过ID获取元素: document.getElementById(“id”) 2, 结果:null或[object HTMLParagraphElement] 3,获取的元素是一个对象,如想对元素进行操作,我们要通过它的属性或方法。
    查看全部
  • <style type="text/css"> body{font-size:12px;} #txt{height:400px; width:600px;border:#333 solid 1px;padding:5px;} p{line-height:18px;text-indent:2em;} </style></head><body><div id="txt"> <h5>JavaScript为网页添加动态效果并实现与用户交互的功能。</h5></div><form> <input type="button" value="改变颜色" onclick="aa()"> <input type="button" value="改变宽高" onclick="bb()"><input type="button" value="隐藏内容" onclick="cc()"><input type="button" value="显示内容" onclick="dd()"><input type="button" value="取消设置" onclick="ee()"> </form> <script type="text/javascript"> //定义"改变颜色"的函数var mytxt=document.getElementById("txt"); function aa(){mytxt.style.color="red";} //定义"改变宽高"的函数function bb(){mytxt.style.width="900px";mytxt.style.height="1000px";} //定义"隐藏内容"的函数function cc(){mytxt.style.display="none";} //定义"显示内容"的函数function dd(){mytxt.style.display="block";} //定义"取消设置"的函数function ee(){ var stylereset=confirm("是否取消设置?");if(stylereset==true) {stylereset.removeAttribute("style");}}</script></body></html>
    查看全部
    0 采集 收起 来源:编程挑战

    2018-03-22

举报

0/150
提交
取消
课程须知
该课程是针对新手的一个简单基础的课程,让您快速了解JS,通过一些简单的代码编写体会JS。如果您已经对JS有所了解,可以跳过本课程,学习JS进阶课程,进一步学习JS相应的基础知识。学习本课程,希望您至少具备HTML/CSS基础知识,认识常用的标签。
老师告诉你能学到什么?
1. 理解JavaScript基础语法; 2. 掌握常用语句的使用方法; 3. 学会如何获取DOM元素及进行简单操作。
友情提示:

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