adding javascript in wordpress posts

I want to implement a simple javascript in my post.

How to add that in wordpress.

Read More

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.

I have the code in simple html and javascript. The code is http://pastebin.com/KqQrMPsu.

Plz can someone help.

Thanks,

Related posts

Leave a Reply

1 comment

  1. 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>
    

    Be sure to put it in your HTML tab instead of your Visual editor.