<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="/reset.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<style>
* {
box-sizing: border-box
}
.container {
width: 100%;
background-color: #ddd;
}
.wrap{width: 1000px; margin:auto;}
.skills {
text-align: right;
padding-top: 10px;
padding-bottom: 10px;
color: white;
}
.html {
width: 10%;
background-color: #4CAF50;
}
.css {
width: 10%;
background-color: #2196F3;
}
.js {
width: 10%;
background-color: #f44336;
}
.php {
width: 10%;
background-color: #808080;
}
</style>
<body>
<div class="wrap">
<h1>My Skills</h1>
<p>HTML</p>
<div class="container">
<div class="skills html">90%</div>
</div>
<p>CSS</p>
<div class="container">
<div class="skills css">80%</div>
</div>
<p>JavaScript</p>
<div class="container">
<div class="skills js">65%</div>
</div>
<p>PHP</p>
<div class="container">
<div class="skills php">60%</div>
</div>
</div>
</body>
</html>
<script>
$(function(){
$('.container').each(function(i){
var skill = $(this).find('.skills');//this=.container 안에 있는 .skill의 값을 읽어서 skill이라는 값에 넣어라
var percent = skill.text(); //skill에 들어있는 값을 percent라는 변수에 넣어라
skill.delay(i*500).animate({'width':percent});//skill을 애니메이트하겠다. percent에 들어있는 값만큼
});
});
</script>