IT/jQuery

jQuery - 이미지 사이즈 변경, 이미지 자동으로 넘김 처리

노마드오브 2018. 11. 18. 20:50

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script>

$(document).ready(function () {

var content = [{name:'홍길동', region:'서울'},

{name:'이몽룡', region:'부산'},

{name:'성춘향', region:'대전'}];

$('div').append(function (index) {   // div에 위 배열의 객체를 하나씩 순서대로 추가

var item = content[index];

return item.name + ':' + item.region;

});

});

</script>

</head>

<body>

<div></div>

<div></div>

<div></div>

</body>

</html>




<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script>

$(document).ready(function () {

// 이미지 width 250 변경. attr()

$('img').attr('width', '250');

//$('img').css('width', '250px');

setInterval(function () {

$('img').first().appendTo('div');   // 제일 첫번째 이미지를 div 태그 제일 뒤에 붙힌다.

}, 2000);

setTimeout(function () {

alert('aaa')

}, 5000);

});

</script>

</head>

<body>

<div>

<img src="cat.png">

<img src="dog.jpg">

<img src="horse.png">

<img src="rabbit.jpg">

</div>

</body>

</html>