0

しばらく潜んでいますが、これが私の最初の投稿です。気楽に行ってください!:-)

「目次」のリストを含むFAQページをテーブルに設定しました。「表示」ボタンをクリックすると、本文が表示されます。

「表示」ボタンをクリックしてdisplay:none trをdisplay:blockに変更する<a href...>と、trのコンテンツにが含まれている場合を除いて機能します。その場合、線を強調表示しない限り、リンクは表示されません。

JSはこんな感じ-

<script> 
    function hidetr(tr) {  
        document.getElementById(tr).style.display="none"; 
    }

    function showtr(tr) {  
        document.getElementById(tr).style.display="block"; 
    } 
</script>

HTMLは次のようになります。

<tr>
    <th>I want to search for registrations in a certain area/by a certain date/by some other criteria that the site does not 
    allow?<button onclick="showtr('faq5')">Show!</button></th>
</tr>
<tr id="faq5" style="display:none"  >
    <td>Please <a href="contactus.php" >Contact Us</a> with a summary of your requirements and purpose and if we are able to help we will do. 
    At this time the search criteria on the site are purposefully limited. </td>
    <td><button onclick="hidetr('faq5')">hide!</button>

何か案は?

更新
では、非表示/表示したい行からスタイルを削除するというリスター氏の提案を考慮して、別の外観がありました。基本的に、リンクはまだ表示されていませんでした。

ページとCSSドキュメントをデスクトップに配置し、CSSから何かをプルダウンしているのではないかと思ったので、そこからページをロードしました。

リンクは、ファイルが保存されている場所以外の変更なしで正しく表示されます。

今、私は本当に混乱しています

アップデート

並べ替えました!まあ...まだですが、私はそれが何であるかを知っているので、ほんの数分かかるはずです。

そのメインページには、いくつかのスタイルマークアップが含まれているナビゲーションバーを含む他のドキュメントのPHPインクルードがいくつかあります。そこに{color:white;}があり、このリンクも白になっています。

ページをPHPではなくHTMLに変更した場合、色が正しいことを発見したので、サーバー側から何かが含まれているに違いないと考えました。

コメントをありがとうございました。1/コードの数ビットを整理するのに役立ちました2/正しい方向に向けてくれました。

リスター氏に特に感謝します。

誰かがこれを閉じてもらえますか。私は7時間新しいので、私自身の質問に答えることはできません。

4

3 に答える 3

1

わかりました、私はあなたの状況を再現し、TR内でDIVを使用して動作させ、TR全体ではなく、CSSクラス名を使用してそのDIVを非表示/表示しました:

CSS

div.hidden{
 display: none;
}
div.normal{
 display: block;
}

JS

function showtr(tr){
 document.getElementById(tr).className = 'normal';
}
function hidetr(tr){
 document.getElementById(tr).className = 'hidden';
}

HTML

<table>
 <tr>
  <th>I want to search for registrations in a certain area/by a certain date/by some other criteria that the site does not 
allow?<button onclick="showtr('faq5')">Show!</button></th>
</tr>
<tr>
 <td>
     <div id="faq5" class="hidden">
         Please <a href="contactus.php">Contact Us</a> with a summary of your requirements and purpose and if we are able to help we will do. At this time the search criteria on the site are purposefully limited.<button onclick="hidetr('faq5')">hide!</button></div>
  </td>
 </tr>
</table>

</p>

于 2012-07-31T17:58:52.110 に答える
0

有効なマークアップが必要です。いくつかのタグがありませんでした。

更新されたコード:

デモ: http: //jsfiddle.net/SO_AMK/dHEdZ/

HTML:

<table>
<tr>
    <th>
        I want to search for registrations in a certain area/by a certain date/by some other criteria that the site does not allow?<button onclick="showtr('faq5')">Show!</button>
    </th>
</tr>
<tr id="faq5" style="display:none">
    <td>
        Please <a href="contactus.php">Contact Us</a> with a summary of your requirements and purpose and if we are able to help we will do. At this time the search criteria on the site are purposefully limited.
        <button onclick="hidetr('faq5')">hide!</button>
    </td>
</tr>
</table>

JavaScript:

function hidetr(tr){  
        document.getElementById(tr).style.display="none"; 
}
function showtr(tr){
        document.getElementById(tr).style.display="block"; 
}​

PS jQueryのようなライブラリを試してみてください。そうすれば、作業がとても楽になります。

于 2012-07-31T17:02:03.860 に答える
0

表示値は要素によって異なります。これが良い解決策であることがわかりました:

function showtr(tr)
{  
    document.getElementById(tr).style.display=""; 
}

これにより、ブラウザは要素タイプのデフォルトを選択できます。

または、jQuery の使用に反対でない場合は、toggle() 関数が非常に優れています。

http://api.jquery.com/toggle/

于 2012-07-31T16:55:41.627 に答える