私信  •  关注

ellipsis

ellipsis 最近创建的主题
ellipsis 最近回复了
5 年前
回复了 ellipsis 创建的主题 » 如何使用Jquery隐藏/显示表中列出的按钮之一?

您可以在不同的元素上使用相同的类名,而不是相同的id

$(".test1").click(function() {
  $(this).siblings(".test2").slideToggle("slow", function() {
    // Animation complete.
    $(".test2").show()
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<html>

<head>
</head>

<body>
  <table>
    <tr>
      <th>Actions</th>
    </tr>
    <tr>
      <td>
        <input type="submit" name="test1" class="test1" value="TEST1" /><br/>
        <input style="display: none;" type="submit" name="test2" class="test2" value="TEST2" /><br/>
      </td>
    </tr>
    <tr>
      <td>
        <input type="submit" name="test1" class="test1" value="TEST1" /><br/>
        <input style="display: none;" type="submit" name="test2" class="test2" value="TEST2" /><br/>
      </td>
    </tr>
  </table>
</body>

</html>

你用错了密码。参考 this

$(function() {
  $(document).keyup(function(e) {
    if (e.which == 49) {
      console.log('1');
      window.location.href = '/';
    } else if (e.which == 50) {
      window.location.href = '/escolas';
    } else if (e.which == 51) {
      window.location.href = '/noticias';
    } else if (e.which == 52) {
      window.location.href = '/eventos';
    } else if (e.which == 53) {
      window.location.href = '/contato';
    }
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
5 年前
回复了 ellipsis 创建的主题 » 如何使用jquery的$.post()发送头?

这就行了。

$.post({
     url: 'xyz',
     headers: { 'header': 'value' }
});
5 年前
回复了 ellipsis 创建的主题 » 无法对特定h1标记应用带有jquery的css

使用 hasClass jquery的功能。如果有问题的元素是否有特定的类,则返回布尔值。

if($("p").hasClass('ABC')) { $(".b,h1").css({'color': 'red'}); }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="b" > <h1>Hello</h1> <div class="a"> 
 <p class="ABC">A........Z</p> 
</div>
</div>