<!DOCTYPE html>
<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 color = ['red', 'blue', 'purple'];
var c = $('h1').css('color');
//alert(c);
//$('h1').css('color', 'yellow');
// $('h1').css('color', function (index) {
// return color[index];
// });
$('h1').css({
color: function (index) {
return color[index]
},
backgroundColor: 'black'
});
});
</script>
</head>
<body>
<h1>head-0</h1>
<h1>head-1</h1>
<h1>head-2</h1>
</body>
</html>
'IT > jQuery' 카테고리의 다른 글
jQuery - append(), appendTo(), prepend() (0) | 2018.10.13 |
---|---|
jQuery - html(), text() (0) | 2018.10.13 |
jQuery $('img').attr('src') (0) | 2018.10.12 |
jQuery button click 이벤트시, each 사용법 (0) | 2018.10.11 |
jQuery 선택자로 css 적용 (0) | 2018.10.11 |