WEB JavaScript jQuery 객체

Develop My Life·2020년 5월 31일
0

WEB JavaScript

목록 보기
7/9

jQuery 암시적 반복

반복문이 보이지는 않지만 암시적 반복을 한다.

예시

<!DOCTYPE html>
<html>
<head>
</head>
<body>
    <li>html</li>
    <li>css</li>
    <li>javascript</li>
    

    
    
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
    var li = $('li');
    li.css('text-decoration','underline'); //암시적 반복
</script>
</body>
</html>

.map( )

  • 유사배열에서 하나하나 마다 호출되는 함수이다.
  • 함수를 인자로 가지며 함수의 인자는 index와 elem 이다.

예시

<!DOCTYPE html>
<html>
<head>
</head>
<body>
    <li>html</li>
    <li>css</li>
    <li>javascript</li>
    

    
    
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
    var li = $('li');
    li.map(function(index,elem){
        $(elem).css('color','yellow');
    })
</script>
</body>
</html>

jQuery API

jQuery가 가지고 있는 다양한 method와 property를 알고 사용할 수 있다.
https://api.jquery.com/

0개의 댓글