如何使用 javascript 将图像添加到元素
我基本上有这个链接,当我点击它时,我希望在它上面显示一个图像。使用 javascript 我怎样才能做到这一点?
<a> click me </a>
CSS:
a.clicked
{
/*what goes here?*/
}
I basically have this link, where when i click it, i want an image to show over it. Using javascript how can i do this?
<a> click me </a>
css:
a.clicked
{
/*what goes here?*/
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
添加新的图像元素非常简单:
因此在 A 元素中:
如果 A 是链接并且您希望取消导航,则返回函数返回的任何内容。如果该函数不返回 false,则将跟踪该链接并应提供等效功能:
Adding a new image element is pretty easy:
so in an A element:
If the A is a link and you wish to cancel navigation, return whatever the function returns. If the function doesn't return false, the link will be followed and should provide equivalent functionality:
你应该这样使用。还有其他几种很好的方法,这只是为了简单和理解的目的
You should use like this. There are several other good methods, this is just for simplicity and understanding purpose
您可能需要的 javascript 插件是 Highslides,请查看此处获取示例。
此处下载 highslides。
The javascript plugin you may need is Highslides, Check here for examples.
Download highslides here.
首先,您可能需要为链接提供一个 ID。
然后对于 JavaScript..
First, you'll probably want to give the link an ID.
Then for the JavaScript..