2011-12-15 2 views
2

클래스가있는 추가 스팬 태그를 감싸기 위해 보유해야하는 HTML이있는 페이지가 있습니다.스팬의 내부 텍스트 가져 오기 및 클래스로 새 스팬으로 랩

<span class="VIEWBOX" id="_Datacomp_c_importantnote"> 
Lorem ipsum dolor sit amet, consectetur adipiscing elit. vestibulum vel tellus. Morbi suscipit enim ac <BR> 
</span> 

내가 부모 범위에있는 클래스/ID를 사용할 수 없습니다 그래서 내가 새로 만들어야합니다.

나는

var innnerNoteText = $('#_Datacomp_c_importantnote').text(); 
innerNoteText.wrap('<span class="noteText"></span>'); 

을 쓴 그러나이 작동하지 않는 경우는, 어떤 도움도 좋은 것입니다!

답변

0

$('...').text() 문자열을 반환있는 방법 wrap이 없습니다.

당신은 jQuery 오브젝트에 wrap() 메소드를 호출 할 수 있습니다

$('#_Datacomp_c_importantnote').wrap('<span class="noteText"></span>'); 

http://jsfiddle.net/EkAPu/

0

$('#_Datacomp_c_importantnote').html('<span class="noteText">' + $(this).text() + '</span>');

관련 문제