Javascript 点击一次图片就会变成文本?

Javascript 点击一次图片就会变成文本?,javascript,jquery,wordpress,onclick,image,Javascript,Jquery,Wordpress,Onclick,Image,我想知道是否有人能帮我。在“关于我们”页面上有每个团队成员的个人资料,下面是他们的电子邮件地址。我想有一个图片,当它消失,并为团队成员的电子邮件地址在它的地方点击图片 该页为- 我对JavaScript或jQuery没有太多经验,但我猜我可以用它们来实现这一点 我试着使用 <div id="email-button"> <img class="email-button-image" onclick="this.style.display = 'none';" alt="E

我想知道是否有人能帮我。在“关于我们”页面上有每个团队成员的个人资料,下面是他们的电子邮件地址。我想有一个图片,当它消失,并为团队成员的电子邮件地址在它的地方点击图片

该页为-

我对JavaScript或jQuery没有太多经验,但我猜我可以用它们来实现这一点

我试着使用

<div id="email-button">

  <img class="email-button-image" onclick="this.style.display = 'none';" alt="Email" src="http://www.thescribblingape.com/wp-content/uploads/2013/06/tSA-Email-Button-post-150x150.png" width="150" height="150" />

   sam@thescribblingape.com

 </div>

对于您的问题,这是一个相对简单的解决方案,尽管我已将文本包装在一个元素中,以便通过CSS轻松定位:

<div id="email-button">
    <img class="email-button-image" alt="Email" src="http://www.thescribblingape.com/wp-content/uploads/2013/06/tSA-Email-Button-post-150x150.png" width="150" height="150" />
    <p>sam@thescribblingape.com</p>
</div>

可以使用jQuery重新编写上述内容,以提供:

$('#email-button').click(function () {
    $(this).find('img, p').toggle();
});

通过重写HTML,您甚至可以只使用HTML和CSS来实现这一点;正在重写为的HTML:

<label for="toggle">
    <input id="toggle" type="checkbox" />
    <img class="email-button-image" alt="Email" src="http://www.thescribblingape.com/wp-content/uploads/2013/06/tSA-Email-Button-post-150x150.png" width="150" height="150" />
    <p>sam@thescribblingape.com</p>
</label>


不幸的是,这确实需要一个相当最新的浏览器。

请在此处发布您的代码。如果你的网站被改变了,这个问题就没有意义了。你能告诉我们你已经写了什么吗?Java?你是说javascript。并在这里提供相关代码,这是一个相当简单的任务,你正在问金希·斯图尔特,似乎你想要一个“标题”的排序。克里斯·科伊尔在这个问题上有着出色的表现。如果这不是你想要的,我建议你搜索一些其他的例子,尝试一下,然后在这里进一步完善你的问题。@NickTomlin谢谢你的链接。对未来有用。但是在这种情况下,我希望图片消失,同时文本出现。
$('#email-button').click(function () {
    $(this).find('img, p').toggle();
});
<label for="toggle">
    <input id="toggle" type="checkbox" />
    <img class="email-button-image" alt="Email" src="http://www.thescribblingape.com/wp-content/uploads/2013/06/tSA-Email-Button-post-150x150.png" width="150" height="150" />
    <p>sam@thescribblingape.com</p>
</label>
label {
    display: block;
    cursor: pointer;
}

label input {
    display: none;
}

label input + img,
label input:checked ~ p {
    display: block;
}

label input:checked + img,
label input ~ p {
    display: none;
}