(1)window.alert:只能确认
window.alert("第一次alert");
alert("第二次alert"); //window可省略
(2)window.confirm:有同意或取消 会回传值
var temp = window.confirm("今天下大雨");
console.log(temp);
setTimeout做了就不回头(似烟火)
setInterval 计时秒数器
setInterval(function () {
cat = cat + 1;
console.log(`累计秒数: ${cat} `);
}, 1000);
setTimeout 更新网址
setTimeout(function () {
document.location.href = "https://one-piece.com/";
}, 3000);
var elm = document.getElementById("cat");
console.log(elm); // 是一个 img 元素
(1)元素.style.top 取得 样式 top 值
必须自己有写CSS才抓的到
var x = elm.style.top;
console.log(`X 的值在这里 => ${x} <=`);
(2)透过 window.getComputedStyle(CSS元素).getPropertyValue('属性'))--------->大绝招抓抓
「预设」的也看的到,所以使用这个!!
var y = window.getComputedStyle(elm).getPropertyValue("top");
console.log(`y 的值在这里 => ${y} <=`); //auto
只会抓第一个,所以id才说不要重复使用!!
<!-- 错误示范 不要使用重复id -->
<h2 id="myApple">Apple</h2>
<h2 id="myApple">Apple-1</h2>
result = document.getElementById("myApple");
console.log(result);
预想未来要装甚麽
result = 0 数字
result = [] 阵列
result = 字串
错误
var x = ""; //使值初始化
正确:先给值
var x = 0;
var x = "这里是文字";
undefined 未来会很难抓 以防程序码变多 debug 困难
""是初始化,javascript 没有初始化也可以,但最好是有
因为没初始化的话,其值会是undefined
var deng = document.images;
if (mybool) {
deng[0].src = "like.png"; //抓阵列第一个[0][1]
mybool = false;
} else {
deng[0].src = "find.png";
mybool = true;
}
indexOf
if (myImg.src.indexOf("like") > -1) {
num1 = myImg.src.indexOf("like"); // indexOf 回传位置并转成数值 29
console.log(num1);
myImg.src = "../../_image/find.png";
} else {
myImg.src = "../../_image/like.png";
}
}
(1)insertBefore:指定在元素前增加 (插队)
(2)appendChild:直接在Html文件中增加元素 (从後面加上)
document.body.insertBefore(newElm, op06);
document.body.appendChild(newImg);
>>: (ISC)² 道德规范(Code of Ethics Canons)
今天我们就来继续做导览列的部分,昨天的HTML已经制作出了导览列的框架,今天就利用CSS来做一些美化...
APP 营运思考 了解开发 APP 目的,不要为了做 App 而做 确认开发需求 商业目标 开发成本...
现在的密码都会有贴心的 张眼模式, 让我们可以看到所输入的密码是否正确, AI2的PasswordT...
在撰写HTML及CSS时,好的命名要具备可读性,一眼就能知道这区块的作用是什麽,也方便日後的维护管理...
您的订阅是我制作影片的动力 订阅点这里~ 影片程序码 library(naniar) data(ir...