在 wordpress 帖子中添加 javascript [英] adding javascript in wordpress posts
问题描述
我想在我的帖子中实现一个简单的 javascript.
I want to implement a simple javascript in my post.
如何在wordpress中添加它.
How to add that in wordpress.
我在帖子中有一张图片,当用户点击图片时,我想显示一个下拉列表.我希望它在帖子中.我在输出和其余代码中得到图像,这意味着 onclick 事件是按 html 格式编写的.
I have an image in the post and when the user clicks on the image i want to display a dropdown. I want it to be in the post. I get the image in the output and the rest of the code that means the onclick event is written as it is in the html format.
我有简单的 html 和 javascript 代码.代码是http://pastebin.com/KqQrMPsu.
I have the code in simple html and javascript. The code is http://pastebin.com/KqQrMPsu.
请有人帮忙.
谢谢,
推荐答案
如果您希望将其放在一个帖子中,您可以使用html"编辑器,而不是Visual"编辑器.选择HTML"选项卡,然后输入
If you want that to be in just one single post, you can use the "html" editor, instead of the "Visual" editor. Select the "HTML" tab, and enter
<script type="text/javascript">
// For: http://www.codingforums.com/showthread.php?t=211072
function changeImg(info) {
if (info == '') { return; }
document.getElementById('mainImage').src = info;
document.getElementById('SBox').style.display = 'none';
}
</script>
请务必将其放在您的 HTML 选项卡中,而不是您的可视化编辑器中.
Be sure to put it in your HTML tab instead of your Visual editor.
这篇关于在 wordpress 帖子中添加 javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!