Adding Javascript to a WordPress blog post.

I want to put a bit of JavaScript into a blog posting.  Here’s an example doing that.

This is an example!

In WordPress, toggle the editor to “Text” and then insert your Javascript similar to the following example.  Here I load jQuery and then use it to animate a div.

<script type="text/javascript" src="/wp-includes/js/jquery/jquery.js"></script>
<script type="text/javascript">
jQuery(function(){
var x = jQuery("#a1148");
var f = x.css('font-size');
var restore = function(){ x.animate({fontSize: f}); };
x.animate({fontSize:'120%'}, restore);});
</script>
<div id="a1148">This is an example!</div>

Leave a Reply

Your email address will not be published. Required fields are marked *