简体   繁体   English

在PHP页面中使用JQuery显示/隐藏

[英]Show/Hide using JQuery in PHP page

I have this code below. 我下面有这段代码。 I am trying to show/hide everything between the #info id. 我试图显示/隐藏#info ID之间的所有内容。 Nothing happens when I click the buttons. 单击按钮没有任何反应。 Where am I going wrong? 我要去哪里错了?

echo '<script>
      $( "#show' . $row['id'] . '" ).click(function() {
      $( "#info' . $row['id'] . '" ).first().show( "fast", function showNext() {
      $( this ).next( "#info' . $row['id'] . '" ).show( "fast", showNext );
      });
      });

      $( "#hide' . $row['id'] . '" ).click(function() {
      $( "#info' . $row['id'] . '" ).hide( 1000 );
      });
      </script>';

echo '<tr><th><button id="show' . $row['id'] . '">Show</button></th>
      <th><button id="hide' . $row['id'] . '">Hide</button></th>';

echo '<div id="info' . $row['id'] . '"><td>L O L</td></div></tr>';

the script is called before the DOM - Element exists. 在DOM-元素存在之前调用脚本。 Do you have some console logs/errors ? 您是否有一些控制台日志/错误? Try to first add the element and then the script tag 尝试先添加元素,然后添加脚本标签

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM