ここにコードがあります。リンクがクリックされたときにのみ長いテキストを表示したいです。
<script src="files/jquery.js"></script>
<center>
<table border="1" bordercolor="#999999" style="background-color:#00000" cellpadding="0" cellspacing="0" width="750">
<tr style="background-color:#00000 height: 50px; width : 250px; font-size: 25px">
<td> <center> Product </center> </td> <td> <center> Description </center> </td> <td> <center> Price </center> </td>
</tr>
<tr>
<td> <a href="#" class="readmore">My product name</a> </td> <td> This is just an introducary description <p class="more">This is a more complex description which should open only when the product name is clicked and here will be also a button to add to cart and some media .</p> <td> <center> <font size="3"> <b> $3 </b> </font> </center> </td> </tr>
</table>
</center>
したがって、長いテキストを非表示にして、製品名のリンクをクリックしたときにのみ表示するためにどのコードを配置すればよいか正確にはわかりません。
編集:うまく開きたいのですが、表示されます。それを説明する方法が正確にはわかりませんが、 http://docs.jquery.com/Tutorialsのように、開くときにjQueryを使用してアニメーション化する必要があると思います:Live_Examples_of_jQuery例 B で Slide In をクリックすると、テキストが美しく表示されます。
多くの変更とテストの後、リンクをクリックするとテキストが開き、アドレスバーで何も変化せず、もう一度クリックすると元に戻すことができるようになりました.
<script type='text/javascript'>
function toggle(id)
{
var el = document.getElementById(id);
if(el.style.display == 'block')
el.style.display = 'none';
else
el.style.display = 'block';
}
</script>
<center>
<table border="1" bordercolor="#999999" style="background-color:#00000" cellpadding="0" cellspacing="0" width="750">
<tr style="background-color:#00000 height: 50px; width : 250px; font-size: 25px">
<td> <center> Product </center> </td> <td> <center> Description </center> </td> <td> <center> Price </center> </td>
</tr>
<tr>
<td> <a href="javascript:void(0)" onclick="toggle('hiddentext');">My product name</a> </td> <td> This is just an introducary description <p class="more" id="hiddentext" style="display: none;">This is a more complex description which should open only when the product name is clicked and here will be also a button to add to cart and some media .</p> <td> <center> <font size="3"> <b> $3 </b> </font> </center> </td> </tr>
</table>
</center>
最後に、私の編集で説明されているようにテキストをうまくスライドさせて、より良い方法でテキストをスライドさせることです。