Using jQuery in a WordPress post

I’m wanting to post live jQuery examples in my WordPress posts, and so need to be able to include working code in the actual post itself. I’ve turned off the WYSIWYG editor and any settings which may mess up my code when I publish. I’ve also, through the exec-php plugin, been able to get php code working in-post, but this (admittedly old) article gave me the impression that Javascript (and by extension, jQuery), would work without a plugin.

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"> </script>
<script type="text/javascript">
$(document).ready(function(){

    $("#test").text("jimmy");

  });
</script>

<p id = "test"></p>

Related posts

Leave a Reply

1 comment

  1. It is dangerous to allow posted code to execute javascript. Its a security hole known as XSS. WordPress probably defaults stripping out javascript tags as a security precaution. There may be a setting you can change this behavior in.