2012-10-26 70 views
-4

我正在嘗試創建一個博客頁面。在我的博客頁面中,我想給出一個鏈接到同一頁面上的地方。我怎樣才能做到這一點與HTML?如何在同一頁面隱藏鏈接的內容?

Ex sort of table of the content 

    |------------------------------| 
    | List of smt     | 
    |  *X      | 
    |  *Y      | 
    |  *Z      | 
    |  *T      | 
    |------------------------------| 

當用戶按下X之類的鏈接之一時,同一頁面將會加載X的內容。 內容X的

|------------------------------| 
    |   X     | 
    | X is .....     | 
    | .......................  | 
    | .. . X is used in .....  | 
    |------------------------------| 
+0

我曾嘗試 gveaf

+0

我真的不是100%肯定你問什麼......聽起來像你在簡單的''與'X' – freefaller

+0

之後,我想給出一個標題列表。然後,如果用戶按下其中一個,則相同的頁面將被加載內容。換句話說,我試圖在同一頁面中存儲鏈接內容。內容隱藏在鏈接後面。 – gveaf

回答

-1

http://www.dynamicdrive.com/forums/showthread.php?49019-jQuery-hide()-and-show()-based-on-a-select-element

Targeting elements to show/hide based on matching ids and classes

<HEAD> 
<script type="text/javascript" src="jquery-1.3.2.js"></script> 
<script type="text/javascript"> 

$(document).ready(function(){ 

    $("#bloc").change(function() { 

    if ($("#bloc").val() == 2) 
    { 
     $("#bdays, #bdays2, #brea, #brea2").show("fast"); 
    } 
    else 
    {  
     $("#bdays, #bdays2, #brea, #brea2").hide(); 
    } 

    }); 

    if ($("#bloc").val() == 2) 
    { 
     $("#bdays, #bdays2, #brea, #brea2").show("fast"); 
    } 
    else 
    {  
     $("#bdays, #bdays2, #brea, #brea2").hide(); 
    } 

}); 
</script> 
</HEAD> 
<BODY> 
<select id="bloc"> 
<option value="1">Normal</option> 
<option value="2">Blocked</option> 
</select> 

<table border="1"> 
    <tr> 
     <td>value 1</td> 
     <td>value 2</td> 
    </tr> 
    <tr> 
     <td> 
      <div id="bdays"> 
      Days: 
      </div> 
     </td> 
     <td> 
      <div id="bdays2"> 
      <input type="text" id="VIN" value=""> 
      </div> 
     </td> 
    </tr> 
    <tr> 
     <td> 
      <div id="brea"> 
      Reason: 
      </div> 
     </td> 
     <td> 
      <div id="brea2"> 
      <input type="text" id="VIN" value=""> 
      </div> 
     </td> 
    </tr> 
</table> 
</BODY> 

嘗試了這一點。

+0

不適用於谷歌博客 – gveaf

0

我不確定這是否會對您有所幫助,但是您可以使用一些CSS來做到這一點?

如果你有一個頁面上的所有東西,你可以用ID做div,然後鏈接到每個ID,它會向下滾動到那個......你可以讓div隱藏在頁面之外,當它們被點擊時它們出現...

如果這聽起來很有用,我可以提供一些代碼

CODE:那麼據我瞭解,你要鏈接到頁面的不同部分(最有可能進一步下跌)

這裏是一個選項並讓我知道它是否對您的問題有效:

{CSS} 
#partofpage { 



} 


{HTML} 
<a href = "#partofpage">Link</a> 

如果你想隱藏一個div或使其可見:

{CSS} 
#partofpagehidden { 

visibily : hidden; /*if you put "Collapse" then it would hide a column/row of a table*/ 
OR 

display: none; /*This would take the element away and it wont take up any space,  visibility would take it away but it would take up the same space*/ 




} 
#partofpageshown { 

visibility: visible; 

} 
+0

你可以提供示例代碼 – gveaf