dimanche 19 avril 2015

JQuery: Change image on page based on class in body

I have a wordpress page where I want to display a featured image on the header of the homepage, but no other pages. I set up a script to read whether the body tag contains the "home" class and display an image based on that. The code looks like this:



<script>
if($('body').hasClass("home")) {
$('#headshot').html('<img src="http://ift.tt/1Ivq4rA" alt="headshot">');
}
</script>


What's wrong with this script?


Aucun commentaire:

Enregistrer un commentaire