confirm方法屬於js的方法,像比如說,window.onload、window.read這些屬於瀏覽器的方法。自己大概知道就好了,其實分太清用處也不是特別大,知道就好了、
下面直接上confirm的示例進行講解。
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<title>js中使用confirm方法</title>
</head>
<body>
<button type="button" id="btn3">呵呵呵呵呵</button>
<script>
/**
$('#btn3').click(function(){
if(confirm('這個是第三個按鈕')){
console.log('呵呵呵');
}
});
**/
document.getElementById('btn3').onclick = function(){
if(confirm('這個是第三個按鈕')){
console.log('呵呵呵');
}
}
</script>
</body>
</html>
自己試試吧,很多地方都會用到的,比如說做了一個商城類的項目,其中有關於刪除
