배열 관련 매서드 실습_jQuery
2022. 1. 21. 11:18ㆍksmart_html_css_js/jQuery 실습
728x90
1.
아래의 버튼 클릭시 모든 행의 텍스트를 ksmart로 변경하시오.
<ul id="ul01">
<li>안녕하세요</li>
<li>안녕하세요</li>
<li>안녕하세요</li>
</ul>
1. 답
<ul id="ul01">
<li>안녕하세요</li>
<li>안녕하세요</li>
<li>안녕하세요</li>
</ul>
<button type="button" id="btn01">클릭</button>
<script type="text/javascript">
$(function(){
var $li = $('#ul01 li');
$('#btn01').click(function() {
$li.each(function() {
$(this).text('ksmart');
});
});
});
</script>
728x90
'ksmart_html_css_js > jQuery 실습' 카테고리의 다른 글
속성 조작 메서드(prop)실습_jQuery (0) | 2022.01.21 |
---|---|
속성 제어 메서드 실습_jQuery (0) | 2022.01.21 |
객체 조작 메서드 실습_jQuery (0) | 2022.01.21 |
배열관련메서드 실습_jQuery (0) | 2022.01.20 |
제이쿼리 선택자 실습_jQuery (0) | 2022.01.20 |