0

单击按钮时,我似乎无法让代码的特定区域淡入淡出。

我已将所有设置#new1-post为隐藏,并且已链接 jQuery 3.4.1。请帮忙!

$(document).ready(function() {
  $(".button1").button().click(function() {
    $("#new1-post").fadeIn();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<div class="new-post-outer">
  <button class="button1" onClick="fadeIn();">Create New Post</button>
  <div class="new-post-mid">
    <form class=a bc>
      <label> New Post: </label><br>
      <input type="text" id="new1-post" class="new-post-title" placeholder="Title">
      <input type="text" id="new1-post" class="new-post" placeholder="Write The Body Of Your Post Here..."><br>
      <label> URL: </label><br>
      <input type="url" id="new-1post" class="new-post-url" placeholder="Please paste relevant URL here"><br>
      <input type="submit">
    </form>
  </div>
</div>

4

1 回答 1

0

您要么必须使用 Button 标签的“onClick”属性,要么在 jquery 中使用“.click()”。还有一点很重要,“你不能对两个或多个项目使用相同的 id,一个 Id 必须始终是唯一的”。

并将所有要淡入的代码放在一个 div 中(更好的代码实践)。

于 2020-02-24T18:45:24.300 回答