728x90
반응형
<!DOCTYPE html>
<!-- src/main/webapp/20220425/attr1.html -->
<html>
<head>
<meta charset="UTF-8">
<title>attr 함수</title>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
</script>
<script type="text/javascript">
$(function(){
//모든 이미지 크기를 200으로 설정
// $("img").attr("width", 200)
//이미지 크기를 100, 200, 300 400 설정
// $("img").attr("width", function(i){
// return (i + 1) * 100
// })
////이미지 크기를 100, 200, 300 400 설정, 높이(height)는 200으로 설정
// $("img").attr("width", function(i){
// return (i + 1) * 100
// }).attr("height", 200)
$("img").attr({"width" : function(i)
{return (i + 1) * 100}
, "height" : 200})
})
</script>
</head>
<body>
<img src="../image/Jellyfish.jpg" />
<img src="../image/Desert.jpg" />
<img src="../image/Hydrangeas.jpg" />
<img src="../image/Chrysanthemum.jpg" />
</body>
</html>
728x90
반응형
'study > Jquery' 카테고리의 다른 글
[Jquery] 21. Jquery event2 (click, hover) (0) | 2022.04.25 |
---|---|
[Jquery] 21. Jquery event1 (on, mouseenter, mouseleave) (0) | 2022.04.25 |
[Jquery] 21. Jquery css 함수 (0) | 2022.04.25 |
[Jquery] 21. Jquery each 함수(let arr=, $.each) (0) | 2022.04.22 |
[Jquery] 21. Jquery 반복문 (nth-child, odd, even, $.each(), let colors = []) (0) | 2022.04.22 |