jQuery 제이쿼리
[객체] 함수를 활용한 속성 부여
chloeize
2021. 5. 12. 00:21
728x90
<img src="" alt="" class="text_box">
<img src="" alt="" class="text_box">
<img src="" alt="" class="text_box">
<script>
$(document).ready(function (){
$('.text_box').attr('height', function(index){
// 단계적으로 크기 적용
return (index + 1) * 100;
// 인덱스 0인 .text_box == (0+1) * 100 => height : 100px
})
})
</script>
<script>
$(function(){
$('img').attr({
width : function (index) {
return (index + 1) * 100;
},
height : 100
});
});
</script>
728x90