2016-10-15 11:38
浏览 39


I'm using jquery to hide all when document ready and when I'm click one of the btn-primary then will be show and hide in accordance with for each of row.


$(document).ready(function() {
$('.btn-primary').click(function() {


<table id="example1" class="table table-bordered table-striped">
                  <tr style="center">
                  <?php  foreach($query as $row):?>
                    <td><?php echo $row->nik ?></td>
                    <td><?php echo $row->nama ?></td>
                    <td><?php echo $row->jabatan ?></td>
                      <div id='buttonmasuk'>
                          <a class="btn btn-sm btn-primary" href="javascript:void()"
  title="Masuk" onclick="masuk('<?php echo $row->id_kar;?>')">Masuk</a></div>
                      <div id='formmasuk'>
                          <input type="text" name="pass">
                          <a class="btn btn-sm btn-danger"  title="Keluar" ></i>
                    endforeach ;?>

this image when document ready. why not all hidden? enter image description here when I click one of the button masuk (class btn-primary) then show enter image description here I want when clik click one of the button masuk (class btn-primary)then show and other still hidden

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dqeq885710 2016-10-15 11:48

    Change your ids to class.

    It should be like the following

    <div class='buttonmasuk'>
    <div class='formmasuk'>

    and the script be like the following

    $('.btn-primary').click(function() {
    打赏 评论
  • duanhe8280 2016-10-15 11:45

    Your html id-s should be unique for the page. Try to add unique id-s to the forms because now you are assingning them the same value "formmasuk"

    打赏 评论
  • dongxue9997 2016-10-15 11:58

    you need to first add Jquery library to your dom add this link in your index.html


    and remove the second line of the code datatable from your script then code is working fine and also please end your script tag properly.

    打赏 评论

相关推荐 更多相似问题