2017-12-05 13 views
0

これは私のテーブルですが、もちろんその中にテキストがあります。ボタンをクリックして隠して、いくつかの画像を表示します。私は同じボタンクリックでアクションを逆にしたい。どうやってやるの?あなたはテーブル全体を写真で置き換える方法は?

を必要として、これは動作しますjQueryの.toggle()方法

$("button").click(function(){ 
    $("img").toggle(); 
}); 

で始めることができます

<div id="aspect" style="display:yes"> 
 
    <table style="100%" id="Table"> 
 
     <tr> 
 
      <th id="textul" > </th> 
 
      <th id="textul4"> </th> 
 
     </tr> 
 
     <tr> 
 
      <td id="testul2and3" style="vertical-align:top"> </td> 
 
      <td style="vertical-align:top" id="textul6"> 
 
       <p> <iframe></iframe> </p> 
 
      </td>           
 
     </tr> 
 
    </table> 
 
</div>

+0

を使用していました} '? –

+0

あなたが話している画像はどこですか? – DaFois

+0

' style = "display:yes" 'は有効ではありませんcss。 – Cerbrus

答えて

1

はこちらをご覧:持ってhttp://api.jquery.com/toggle/

+0

あなたは質問に対するあなたの編集内容がどのように受け入れられたのかわかりませんが、 – Cerbrus

+0

どうしたらいいのですか?trのインラインスタイルですか? – DaFois

+0

質問のコードを変更しないでください(インデントfまたは可読性)。 – Cerbrus

0

してください見えるこのコードサンプルで。隠された:私はあなたが `hidden`属性(ここでサポートされている)、または単に.hidden {ディスプレイ` `として定義.hidden`クラスを(切り替えしようとしましたjQueryの2.1.1

$(function() { 
 
    $('#toggler').click(function() { 
 
    $('#Table').toggle(); 
 
    $('#imageblock').toggle(); 
 
    }); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div id="aspect"> 
 
<div style="display:none;" id="imageblock"> 
 
<img src="http://lorempixel.com/400/200/" /> 
 
</div> 
 
<table id="Table"> 
 
<tr> 
 
    <th id="textul" > </th> 
 
    <th id="textul4"> </th> 
 
    </tr> 
 
    <tr> 
 
\t \t <td id="testul2and3" style="vertical-align:top"> </td> 
 
    \t \t <td style="vertical-align:top" id="textul6"> 
 
      <p> <iframe></iframe> </p> </td>           
 
    </tr> 
 
    </table> 
 
</div> 
 
<button id="toggler">Toggle Image/Table</button>

関連する問題