2014-04-09 3 views
1

페이지로드시 코드 블록을 둘러싼 앵커 요소를 제거하고 싶습니다.jquery를 사용하여 페이지로드시 부모 또는 자식 요소 제거

페이지가로드, 나는이 코드를 원하는 경우 :

<h3 class="ms-standardheader ms-WPTitle" style="text-align: justify;"> 
<a accesskey="W" href="#"> 
<nobr> 
<span>Employee Announcements</span> 
<span id="WebPartCaptionWPQ3"></span> 
</nobr> 
</a> 
</h3> 

이 코드로 전환하려면 :

<h3 class="ms-standardheader ms-WPTitle" style="text-align: justify;"> 
<nobr> 
<span>Employee Announcements</span> 
<span id="WebPartCaptionWPQ3"></span> 
</nobr> 
</h3> 

나는이 작업을 사용하여 포장을 벗긴를 얻기 위해 시도했지만 난 아직도 내가 때문에 고군분투를 주변 nobr 요소를 떠나고 싶다.

+0

nobr은 무엇인가? 'Oo' – Stphane

+0

@ f00bar - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/nobr – j08691

+0

@ j08691 감사합니다! ... 아직도 그 태그는 표준 HTML이 아니므로 사용해서는 안됩니다. 같은 행동을 CSS로 얻을 수있다. – Stphane

답변

0
$(function() { 
    var target = $('a[accesskey="W"]'); 
    var keep = target.children(); 
    target.replaceWith(keep); 
}); 
관련 문제