jqueryBasic2.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>제이쿼리연습2</title>
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<script>
$(document).ready(function(){
$('.cooking > img').on({
'click': function() {
var src = ($(this).attr('src') === 'image/icon0.svg')
? 'image/icon1.svg'
: 'image/icon0.svg';
$(this).attr('src', src);
}
})
});
$(document).ready(function(){
$(".btn").hover(function(){
$(this).css({
"background" : "skyblue",
"transition" : "0.7s"
})
}, function(){
$(this).css({
"background" : "deeppink",
"transition" : "0.5s"
})
})
});
$(document).ready(function(){
$(".modal_btn").click(function(){
$(".popup_bg").css({"display" : "block"});
});
$(".popup_bg").click(function(){
$(this).css({"display" : "none"});
});
});
</script>
<style>
.popup_bg {
display: none;
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
}
.popup {
position: absolute;
left: calc(50% - 150px);
top: calc(50% - 250px);
width: 300px;
height: 500px;
background-color: #fff;
}
.modal_btn {
width: 100px;
height: 40px;
font-size: 30px;
line-height: 40px;
background-color: deeppink;
color: #fff;
text-align: center;
cursor: pointer;
}
.btn {
width: 100px;
height: 40px;
font-size: 30px;
line-height: 40px;
background-color: deeppink;
color: #fff;
text-align: center;
cursor: pointer;
}
</style>
</head>
<body>
<div class="cooking">
<img src="image/icon0.svg">
</div>
<div class="btn">메뉴1</div>
<div class="btn">메뉴2</div>
<div class="btn">메뉴3</div>
<div class="btn">메뉴4</div>
<div class="btn">메뉴5</div>
<div class="popup_bg">
<div class="popup"></div>
</div>
</body>
</html>