js常识

来源:互联网 发布:淘宝企业店铺搜索 编辑:程序博客网 时间:2024/06/05 11:37
http://docs.apicloud.com/Dev-Tools/webStorm-apicloud-plugin
js常识
1.输出到界面用document.write(),弹出对话框用alert
2." "空格
3.<ul>list-style: none消除无序列表前的点.<a>text-decoration: none消除无序列表的底线
4.id一般用#定义,class类一般用.定义,margin:0;padding:0顶边设置;margin:0 auto;与上边距距离为0,水平居中margin(上右下左)
  ul{list-style: none;padding-left:10px;}表示标签距左边距为10px;overflow: hidden超出隐藏
5.box=document.getElementById("box");找到box的地址 box.innerHTML获取box中的内容
6.timer=setInterval(a,50);每隔50ms执行a,执行多次;setTimeout("a",50);每隔50ms,setTimeout 运用在延迟一段时间,再进行某项操作,默认只执行一次。
clearInterval(timer);暂停工作
7.cursor: pointer鼠标变为小手
8.display: none内容不显示。display: block内容显示
9. <div id="buttons">
        <span index="1" class="on"></span>
        <span index="2"></span>
        <span index="3"></span>
    </div>
buttons=document.getElementById("buttons").getElementsByTagName("span");获取id为buttons下的span标签。font-weight: bold字体加粗
10.parseInt()强制转化为int型
11.setAttribute("style","width:100px;height:50px");//设置id
12.document.getElementsByTagName("li");//    找到li标签
   alert(lis[i].getAttribute("title"));//获取并输出有title的title值的内容
13.<span class="con" name="my"></span>,alert(document.getElementsByClassName("con").length);//得到类名为con的个数
    alert(document.getElementsByName("my").length);//得到名字为my的个数
    document.getElementsByTagName("div")通过标签名获取div
1 0
原创粉丝点击