2012-11-20 2 views
1

내 사이트에 객체를 임베드하고 div를 제거하고 싶습니다. 그게 가능하니? jQuery를 사용하여 객체 태그 안에 특정 ID가있는 div를 제거하려고합니다. 아래 jQuery 시도했지만 div 포함 된 개체 안에 선택하지 않습니다.jQuery를 사용하여 내장 객체 내부에서 div를 제거하십시오.

$("div").filter(function(){ 
console.log(this.id); // i don't see any of the id's from the div's inside my object 
}); 

편집 :

<object data=http://www.msn.com width='100%' height='100%'> 
<embed src=http://www.msn.com width='100%' height='100%'> 
</embed> Error: Embedded data could not be displayed. </object> 

나는 내 사이트에 포함 된 개체 내부 사업부를 제거해야합니다.

도와주세요.

감사

+0

'this.id'를 대신 사용하십시오. 'id' 속성이없는 jQuery 객체를 만들고 있습니다. – undefined

+0

'this.id' 또는'$ (this) .attr ('id')' –

+0

대신 $ (this) .id 대신에 ?undefined를 사용하십시오. – milan

답변

1
$(this).attr('id') // $(this) is jQuery Object 

또는

this.id // this is DOM Object 

/

$("div").filter(function(){ 
     return this.id != 'div1' && this.id != 'div2' ; 
}).css('backgroundColor' , 'orange')​ 

Check Fiddle

+0

제 질문을 다시 읽어주십시오. 더 잘 설명하기 위해 수정했습니다. 덕분에 – milan

+0

$ (this) .prop ('id') id는 속성이 요소이기 때문에 아마도 this.id와 더 일관성이 있습니다. - 속성 '.' 표기법을 주목하십시오. –

+0

@wirey .. 그 점을 지적 해 주셔서 감사합니다 ... id는 요소의 속성이 아니라 오히려 속성이라고 생각합니다. attr() 대 .prop()의 관점에서 나에게 말하면, 정적 속성에 대해서는 문제가 될 것이라고 생각하지 않습니다. . –

관련 문제