【问题标题】:"popover image" - having trouble re-hiding the image after it pops up“弹出图像” - 弹出后无法重新隐藏图像
【发布时间】:2023-04-10 13:58:01
【问题描述】:

您好,我目前有一个button_to 和一个名为basic(1).png 的图像,我想进行放大显示。当点击图片时,更大的克隆将show。这目前有效!但是,当我单击cloned image 时,我希望能够再次隐藏cloned image

  • 如何在点击时隐藏第二个克隆图像?

<script type="text/javascript">
  $(function() {
    $('#background-image-basic1').hide();
  });
</script>

<div id="basic-1" style="height:100%;width:50%;display:inline-block;float:right;">
  <%= button_to 'javascript:;', :class => "view-popover1", :rel => "popover" do %>

    <%= image_tag("basic(1).png", :alt => "basic(1).png", class: "img-responsive ", style:"border-radius:6px;" ) %>

      <% end %>
</div>


<%= button_to 'javascript:;', :class => 'background-image-basic1', :rel => "popover", :id => "background-image-basic1" do %>
  <%= image_tag("basic(1).png", :alt => "basic(1).png", class:"img-responsive thumbnail-instructions ", style:"border-radius:6px;" ) %>
    <% end %>


      
      <script type="text/javascript">
        $('.view-popover1').click(function() {
            $('#background-image-basic1').show();
          }),
          $('.background-image-basic1').click(function() {
            $('#background-image-basic1').hide();
          });
      </script>

【问题讨论】:

  • 你能给我们渲染的 HTML 吗?这里的rails代码似乎没有必要,看起来只是html/css/js的问题。
  • @MichaelCoker 点击事件处理程序中的错字,应该是$('#background-image-basic1').click...?
  • 当我更改为('#background-image-basic1')时仍然做同样的事情
  • 我把它改成link_to

标签: javascript jquery html css ruby-on-rails


【解决方案1】:

错误

&lt;%= button_to %&gt;

正确

&lt;%= link_to %&gt;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-17
    • 2017-02-02
    • 2020-10-03
    相关资源
    最近更新 更多