この下がありません。
display:noneで表示されない状態です。
前回の質問を応用させた質問をします。
前回の質問で、htmlの一部をdisplay:noneにして、クリック時のみ表示する方法を学びましたが、
html
1<html> 2<head> 3<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> 4</head> 5<body> 6<script> 7 $(function(){ 8 $(".section_trigger_1").on("click",function(){ 9 $(".section_box").hide(); 10 $(".section_box_1").show(); 11 }) 12 $(".section_trigger_2").on("click",function(){ 13 $(".section_box").hide(); 14 $(".section_box_2").show(); 15 }) 16 $(".section_trigger_3").on("click",function(){ 17 $(".section_box").hide(); 18 $(".section_box_3").show(); 19 }) 20 $(".section_trigger_all").on("click",function(){ 21 $(".section_box").show(); 22 }) 23 $(".section_trigger_hide").on("click",function(){ 24 $(".section_box").hide(); 25 }) 26 }) 27</script> 28<style> 29.section_box{ 30 display:none; 31} 32</style> 33<h3 id="menu">メニュー</h3> 34<ul> 35 <li class="section_trigger_1">セクション1</li> 36 <li class="section_trigger_2">セクション2</li> 37 <li class="section_trigger_3">セクション3</li> 38 <li class="section_trigger_all">全部表示させるよ</li> 39 <li class="section_trigger_hide">全部隠すよ</li> 40</ul> 41<div class="section_box_1 section_box"> 42 <h3>セクション1</h3> 43 <p>セクション1の段落。 ...</p> 44</div> 45<div class="section_box_2 section_box"> 46 <h3>セクション2</h3> 47 <p>セクション2の段落。 ...</p> 48</div> 49<div class="section_box_3 section_box"> 50 <h3>セクション3</h3> 51 <p>セクション3の段落。 ...</p> 52</div> 53</body> 54</html> 55
これを応用したhtmlを作成したいです。
以下が僕が応用したコードですが、これだとdisplay:noneで囲った部分がdisplay:noneになりますが、クリックしても表示されません。
参考したコードがjavascriptのため、phpのコードに入れるには何を細くするべきですか?
※javascriptのコードをphpのコードを入れるにはEOFを使うことを知っていますが、EOFを使ってみても変わりません。
php
1<head> 2<script> 3function panelChange(panel){ 4 var check_panel; 5 check_panel = document.forms["form_menu"].elements[panel].checked; 6 if(check_panel){ 7 document.getElementById(panel+"_table").style.display="block";; 8 }else{ 9 document.getElementById(panel+"_table").style.display="none";; 10 } 11} 12 13</script> 14</head> 15
を<head></haed>に入れ、htmlを
echo '<input type="checkbox" id="Panel1" onclick="panelChange(this.id);">';
echo '<table class="menu" width=100>';
echo '<caption class="class">';
echo '<label for="Panel1">';
echo $r->name;
echo '</label>';
echo '</caption>';
echo '</td>';
echo '</tr>';
echo '<tbody class="panel_table" id="Panel1_table">';
echo '<tr>';
echo '<th>';
echo 'アクセス';
echo '</th>';
echo '<td>';
echo $r->access;
echo '</td>';
echo '</tr>';
echo '</tbody>';
echo '</table>';
echo '</form>';
echo '</table>';
にしました。
アクセスをdisplay:noneにしてクリック時に表示したいです。
※全体のコードを提示します。
echo '<td>'
echo $r->access以下を非表示表示にしたいです。
<?php $key='私のkey'; $count='10'; $large_area='〇〇'; $start ='2'; $format='xml'; $url='http://webservice.recruit.co.jp/hotpepper/gourmet/v1/?key='.$key.'&count='.$count.'&large_area='.$large_area.'&start='.$start.'&format='.$format; $xml=simplexml_load_file($url); if(!$xml->test){ echo '見つかりませんでした'; } else { foreach($xml->test as $r){ echo '<table>' ; echo '<tr>'; echo '<td>'; echo $r->name; echo '</td>'; echo '<td>'; echo $r->access; echo '</td>'; echo '</tr>'; echo '</table>'; } } ?>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/09/26 10:38
2016/09/27 02:23
2016/09/27 02:24
2016/09/27 03:22
2016/09/27 03:26
2016/09/27 03:27
2016/09/27 03:28
2016/09/27 03:34
2016/09/27 03:37
2016/09/27 04:22 編集
2016/09/27 04:28
2016/09/27 04:38
2016/09/27 04:47
2016/09/27 04:48
2016/09/27 04:49
2016/09/27 06:56
2016/09/28 07:54
2016/09/28 08:02
2016/09/28 08:11
2016/09/28 08:13
2016/09/28 08:19
2016/09/28 08:35
2016/09/28 08:37
2016/09/28 08:52
2016/09/29 05:10
2016/09/29 05:14
2016/09/29 05:25
2016/09/29 05:28
2016/09/29 05:29