(jquery 강좌)size( ) : 매치되어진 원소들의 개수를 반환한다.
제이쿼리size강좌교육,jQUERY사이즈함수,제이쿼리구로디지털단지교육학원,jquery-1.10.2.min.js
● size( ) Returns: Number
size( ), 실행 후 숫자를 반환
매치되어진 원소들의 개수를 반환한다.
<html><head>
<style>
body {
cursor: pointer;
}
div {
width: 50px;
height: 30px;
margin: 5px;
float: left;
background: blue;
}
span {
color: red;
}
</style>
<script src="/ajaxjquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(document.body).click(function () {
$(document.body).append($("<div>"));
var n = $("div").size();
$("span").text("There are " + n + " divs. Click to add more...");
}).click(); // trigger the click to start
});
</script>
</head>
<body>
<span></span>
<div></div>
</body>
</html>
<style>
body {
cursor: pointer;
}
div {
width: 50px;
height: 30px;
margin: 5px;
float: left;
background: blue;
}
span {
color: red;
}
</style>
<script src="/ajaxjquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(document.body).click(function () {
$(document.body).append($("<div>"));
var n = $("div").size();
$("span").text("There are " + n + " divs. Click to add more...");
}).click(); // trigger the click to start
});
</script>
</head>
<body>
<span></span>
<div></div>
</body>
</html>
댓글 없음:
댓글 쓰기