2009-11-09 10 views

답변

0
$('#some_text:first-child').html(); //contains your text 

$('#some_text:first-child').remove(); //to remove 
0

사용 replaceWith() :

$("#some_text > p").replaceWith("some other html"); 

또는 좀 더 구체적으로해야하는 경우 :

$("#some_text").children().not("#child").replaceWith("some other html"); 

replaceWith() 의지 담당자 : 심지어

$("#some_text > p:first-child").replaceWith("some other html"); 

또는 not()를 사용 레이스 은 특정 HTML과 일치하는 요소이므로 두 개 이상 일치하면 중복 된 콘텐츠가 표시됩니다. 다른 방법은 HTML을 제거한 다음 원하는 HTML을 추가하는 것입니다.

기본적으로 새 HTML을 넣기 때문에 하위 요소를 유지하면서 div 내에서 HTML을 바꾸는 것은 어렵습니다. 그 전에? 후? 약? 아마도 좀 더 구체적 일 필요가있을 것입니다.

0

$('#sometext > p') 트릭을해야합니다.

0

0x3이 (가) :nth 자식에 대해 :first-child:parent과 같은 의사 선택기를 사용하지 않으려 고합니다.

관련 문제