JS 节点相关操作

<style> #content { width:800px; height:500px; border:solid 1px #ddd; margin: 0 auto; } .item { width:100px; height...

Read more

JS DOM

DOM简介HTML文档中的每个元素都是一个节点无论是标签 标签属性 文本 注释甚至空白都算是一个节点 查找元素 通用方法 document.getElementById 通过id属性来查找元素document.getElementsByTagName 通过标签名来查找元素document.getElementsByClassName 通过类名来查找元素document.getEl...

Read more

JS 抽奖

<style> #abc { width:300px; height:200px; margin: 0 auto; border:solid 1px #ddd; text-align:center; font-size:30px; line-heigh...

Read more

JS scrollTo scrollBy

scrollTo scrollBy#c { width:100px; height:50px; background:#eaf; position:fixed; right:0px; top:100px; } <div style="width:200px;margin:0 auto;height:auto;background...

Read more

JS 常用的方法

1. 信息提示框 alertalert('外面干啥呢??'); 2. 信息确认框 confirmvar res = confirm('你确定要离开么???'); 3. 获取用户的输入 prompt() 对话框alert('为了确保推算的准确性, 请您如实的填写信息!!!!'); var user = prompt('请输入您的名字!!'); var age = prompt('请输...

Read more

JS BOM frames子对象

<body style="background:pink"></body> // f_1.html // f_2.html <body style="background:orange"> <script type="text/javascript"> //获取父级元素窗口的window对象 // parent 是用来...

Read more

JS BOM history子对象

属性: length方法: back() forward() go(1) <a href="h_1.html">h_1</a> <a href="h_2.html">h_2</a> <a href="h_3.html">h_3</a> <button id="f">前进</button> ...

Read more

JS BOM screen子对象

window.screen 对象包含有关用户屏幕的信息<div style="width:2000px;height:3000px;"></div>console.log(window.screen); 获取整个屏幕的宽度和高度var w = window.screen.width; var h = window.screen.height; 浏览器的可用宽度和高...

Read more

JS BOM navigator子对象

navigator需要在JS中获取客户端信息的时候 <?php echo '<pre>'; var_dump($_SERVER);die; //获取当前请求的userAgent $userAgent = $_SERVER['HTTP_USER_AGENT'];// lamp userAgent // var_dump(strp...

Read more

JS 样式获取 window.getComputedStyle

使用getComputedStyle获取元素样式的时候,一定要将样式的名称写完整 #test { border:solid 1px #ddd; } <div style="width:200px;height:200px;background:orange" id="test"></div> <script type="text/javascri...

Read more