javascript-初级-day01-属性操作、图片切换、短信发送模拟


大多数js就是操作一些css和html的技巧,如果你会html和css学习js更加轻松哦!
js中如何获取元素:
通过id名称来获取元素;
    document get element by id 'link'
    document.getElementById("link");

事件: 鼠标事件,键盘事件,系统事件,表单事件,自定义事件。
onclick
onmouseover
onmouseout
onmousedown
onmouseup
onmousemove 就像鼠标抚摸一样的事件
...

onload     加载完成以后执行...
window.onload=事情
img.onload 
body.onload
...

如何添加事件
    元素.onmouseover
    
函数:命令,做一些事情
function abc(){//不会主动执行
....
}
//1.直接调用函数
abc();
//2.事件调用: 元素.事件=函数名  xxx.onclick=abc;

function(){};//匿名函数
 //匿名函数调用事件
 元素.事件=function(){}
 
 
 测试:
 alert("ok");//"ok"字符串 alert确定按钮的警告框
  
  变量:
  var li=document.getElementById("lis");
 var num 123;
 var name="leo";

 day01-小练习




"Content-Type" content="text/html; charset=utf-8">
无标题文档







"text1" type="text" />
<select id="select1">
    
    
    
select>
"btn1" type="button" value="按钮" />


 day02 -文本输入路径-点击按钮-切换图片




"Content-Type" content="text/html; charset=utf-8">
无标题文档







"text1" type="text" />
"btn1" type="button" value="按钮" />

"p1">这是一些文字

"img1" src="img/1.jpg" width="200" />

day03-test文本数据插入到p标签中




"Content-Type" content="text/html; charset=utf-8">
无标题文档







"text1" type="text" />
"btn1" type="button" value="按钮" />

"p1">这是一些文字

day04-文字的放大缩小




"Content-Type" content="text/html; charset=utf-8">
无标题文档





"btn1" type="button" value="-" />
"btn2" type="button" value="+" />

"p1" style="font-size:16px;">10月28日晚,中央纪委监察部官网发布消息,贵州省委常委、遵义市委书记廖少华因涉嫌严重违纪违法接受组织调查。3天后中组部宣布对其免职。廖成为十八大后中纪委一连串"打虎"行动中第十一位落马的副省部级以上高官。

day05-文字的放大缩小-旁边切换颜色




"Content-Type" content="text/html; charset=utf-8">
无标题文档






"btn1" type="button" value="-" />
"btn2" type="button" value="+" />
"btn3" type="button" value="" />
"btn4" type="button" value="" />

"p1" style="font-size:16px;">10月28日晚,中央纪委监察部官网发布消息,贵州省委常委、遵义市委书记廖少华因涉嫌严重违纪违法接受组织调查。3天后中组部宣布对其免职。廖成为十八大后中纪委一连串"打虎"行动中第十一位落马的副省部级以上高官。

day06-相对路径的问题-不能拿相对路径做判断




"Content-Type" content="text/html; charset=utf-8">
无标题文档





"img1" src="img/1.jpg" width="400" />


使用要用绝对路径判断

day07-关于表单元素的属性值修改问题




"Content-Type" content="text/html; charset=utf-8">
无标题文档




"inp1" type="text" />




day08-聊天功能




"Content-Type" content="text/html; charset=utf-8">
无标题文档






"div1">
"strong1">张三: "text1" type="text" /> "btn1" type="button" value="提交" />

day09-if判断




"Content-Type" content="text/html; charset=utf-8">
无标题文档






"div1">
"strong1">张三: "text1" type="text" /> "btn1" type="button" value="提交" />

day10-图片切换




"Content-Type" content="text/html; charset=utf-8">
无标题文档





"img1" src="img/2.jpg" width="200" />




day11-数组




"Content-Type" content="text/html; charset=utf-8">
无标题文档







day12-用数组切换图片




"Content-Type" content="text/html; charset=utf-8">
无标题文档





"img1" src="img/1.jpg" width="400" height="400" />


day13-图片切换综合实例




"Content-Type" content="text/html; charset=utf-8">
无标题文档






"button" value="循环切换" />
"button" value="顺序切换" />


"box">图片可从最后一张跳转到第一张循环切换 "prev" href="javascript:;">< "next" href="javascript:;">>

"p1">图片文字加载中……

"strong1">图片数量计算中…… "img1" />

相关