제이쿼리 replace 질문

제이쿼리 replace 질문

QA

제이쿼리 replace 질문

답변 1

본문

<div id="hello">

<table>

<thead>

<tr>

<td>ab a</td>

<td>b a a</td> 

<td>caa</td> 

</tr>

</thead>

<tbody>

<tr>

<td>a</td>

<td>b</td> 

<td>c</td> 

</tr>

</tbody>

</table>

<ul>

<li>a</li>

<li>b</li> 

<li>c</li> 

</ul>

</div>

 

 

#hello 안에 있는 모든 a 를 b 로 바꾸고 싶습니다.. 도움부탁드립니다

이 질문에 댓글 쓰기 :

답변 1

$('#hello td, #hello li').each( function() {

    $(this).text( $(this).text().replace(/a/g, 'b') );

})


감사합니다 $('#hello td, #hello li') 에서 td랑 li를 딱히 안정해주고  #hello의 모든 자식에 대해 하려면 어떻게해야 하나요?

$(#hello).find().each(function() { 로 해보니 find에 자식을 정해줘야 실행이됩니다

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 129,117
© SIRSOFT
현재 페이지 제일 처음으로