2012-10-01 41 views
0

如何從div中刪除一個段落(p1)?這是我的完整HTML和CSS:http://jsfiddle.net/8Q3YH/如何隱藏div中的p1

我想從下面完全刪除p1。

<div id="quickSummary"> 
     <p class="p1"><span>A demonstration of what can be accomplished  visually through <acronym title="Cascading Style Sheets">CSS</acronym>-based design. Select any style sheet from the list to load it into this page.</span></p> 
     <p class="p2"><span>Download the sample <a href="zengarden-sample.html" title="This page's source HTML code, not to be modified.">html file</a> and <a href="zengarden-sample.css" title="This page's sample CSS, the file you may modify.">css file</a></span></p> 
    </div> 

回答

1

與CSS,你會做

#quickSummary .p1 { display:none; } 

這個隱藏與P1級

的元素,你可以使用僞類,但並非所有瀏覽器都支持尚未

那將是

#quickSummary p:first-child { display:none; } 

這意味着,quickSummary中的第一個段落標記將被隱藏。

希望這會有所幫助。

+0

非常感謝!我認爲這是#quickSummary p1或p1跨度。 – Kronos

+0

不客氣! –

0

使用此CSS類你的頁面

.p1{display:none;} 
0

上試試這個

#quickSummary .p1{display:none; } // to hide the element 

CSS,你只能隱藏元素(瀏覽器不可見)。 從DOM中徹底刪除它,你可以使用jQuery

$('#quickSummary').find(".p1").remove(); 
+0

查詢<<< ....... –

+0

@ Mr.Alien謝謝 – Champ

+0

隨時;)..... –

0

CSS?

.p1 { 
display:none; 
} 

另外;不需要將整個頁面粘貼到JsFiddle中 - 只需要粘貼您遇到問題的標記位即可。

0

這取決於您的需要。

使用使用jQuery

$('div#quickSummary .p1').hide(); 
1

CSS

div#quickSummary .p1 
{ 
display:none; 
} 

你可以像下面這樣做

#quickSummary .p1 {display: none;} //This will empty the space on your web page 

#quickSummary .p1 {visibility: hidden;} //This will hide the paragraph but will reserve the space 
+0

+1 For hidden .. –

0

有CSS中許多選項,如

display:block;  (or) /* text is absent */ 
visibility:hidden; (or) /* text is present but in hidden state */ 
color:transparent; /* text is present but in hidden state */ 

例:

.p1, .p1>a {color:transparent;} 

否則使用jQuery刪除p標籤。

0

嘗試CSS3僞選擇器 - 這樣你就不需要類。請注意,儘管在舊版瀏覽器中無效。

嘗試

#quickSummary li:first-of-type{ 
display:none; visibility:hidden; 
}