Green-JEONG / Web

Web 프로그래밍 학습
0 stars 0 forks source link

[Updated] JavaScript(web2)_12 #22

Open Green-JEONG opened 4 weeks ago

Green-JEONG commented 4 weeks ago

1. Loop(반복문)

(1)

<script>
    document.write('<li>1</li>');
    var i = 0;    // The value of i is curretly 0 (i의 값은 현재 0)
    while(i < 3) {
        document.write('<li>2</li>');
        document.write('<li>3</li>');
        i = i + 1;
    }
    document.write('<li>4</li>');
</script>

(2) Insert link

<script>
    var i = 0;
    while(i < coworkers.length) {
        document.write('<li><a href="http://a.com/'+coworkers[i]+'">'+coworkers[i]+'</a></li>');
        i = i + 1;
    }
</script>

(3) Utilization - Output all <a>

var alist = document.querySelectorAll('a');
var i = 0;
while(i < alist.length) {
    console.log(alist[i]);
    i = i + 1;
}
Green-JEONG commented 4 weeks ago

It took a total of 30 minutes.