请告诉我如何从图像创建切换?

Please tell me how to create a toggle out of an image?

我想要 window 中的多张图片。当我点击一张图片时,我想切换显示一些信息。我希望在我所有的图像上都有这个。

您没有 post 您正在使用的技术,所以我假设您正在使用 jQuery 和 html:

这是 html 示例:

<div>
  <img class="img" data-imgid="img1" src="https://i2.wp.com/beebom.com/wp-content/uploads/2016/01/Reverse-Image-Search-Engines-Apps-And-Its-Uses-2016.jpg?w=640&ssl=1" width="200px" />
  <br/>
  <text style="display:none;" id="img1">Image1 ......</text>
  <br/><br/>
  <img class="img" data-imgid="img2" src="http://www.111ideas.com/wp-content/uploads/2018/01/download-rose-image.jpg" width="200px" />
  <br/>
  <text style="display:none" id="img2" class="text" hide>Image2 </text>
  <br/><br/>
  <img class="img" data-imgid="img3" src="https://processing.org/tutorials/pixels/imgs/tint1.jpg" width="200px" />
  <br/>
  <text style="display:none" id="img3" class="text" hide>Finally Image3 :)</text>
</div>

这里是 jQuery 处理切换的代码 process.You 需要使用基于 onclick 函数内 html 代码中任何文本标签的 ID 的切换方法来切换它:

$(function () {
            $('.img').on('click', function () {
                var txtId = $(this).attr('data-imgid');
                $('#' + txtId).toggle();
            });                   
    });

您可以在此处观看现场演示: http://jsfiddle.net/gtU56/342/