2014-09-18 7 views
-1

이미 3 가지 해결책을 시도했지만 작동하지 않았습니다.html 주석 태그가있는 jQuery 랩

덧글 태그로 내 사이드 ​​바를 감싸고 싶습니다.

최초의 솔루션 :

$("#sidebar").wrap("<!--googleoff: index--><!--googleon: index>"); 

두 번째 솔루션 :

이 게시물에서 : jQuery comment/uncomment <!--element-->

function comment(element){ 
    element.wrap(function() { 
     alert(this.outerHTML); 
     return '<!--googleoff: index-->'+this.outerHTML+'"<!--googleon: index>'; 
    }); 
} 
comment($('#sidebar')); 

세 번째 솔루션 :

$('#sidebar').prepend("<!--googleoff: index-->"); 
$('#sidebar').append("<!--googleon: index>"); 

내가 원하는 결과 :

<!--googleoff: index--> //start comment tags 
<div id="sidebar"></div> 
<!--googleon: index> // tags 

답변

0

보십시오.

$('#sidebar').before("<!--googleoff: index-->"); 
$('#sidebar').after("<!--googleon: index-->"); 
+0

작동하지 않았습니다. 소스를 볼 때 주석 태그를 찾을 수 없습니다. – Jows

+0

크롬을 사용하는 경우 마우스 오른쪽 버튼을 클릭 한 다음 "페이지 소스보기"가 아닌 "요소 검사"를 클릭하십시오. 페이지 소스는 현재 Dom 요소가 아닌로드 된 Dom 요소를 의미합니다. – easywaru

+0

예. 감사합니다. – Jows