I am trying to execute a single JavaScript function on my wordpress site. The idea is to cause a image to appear in the viewport div when someone mouses over a link (nav .home a). I cannot get this to work for the life of me.
Here is the HTML: I placed this in my header head between stylesheet and meta tags
<script type="text/javascript" src="/scriptfile.js"></script>
Then I ran the script in the viewport div:
<div class="viewport">
<script type="text/javascript">
<!--
preview();
//--></script>
</div>
here is the file (scriptfile.js):
function preview()
{
var hoverhome = 'url("images/Screen2.png") no-repeat';
var empty = '';
$(document).ready(function()
{
//home
$('nav .home a').mouseover(function(){
$('.viewport').css('background-image', 'url(' + hoverhome + ')');
});
$('nav .home a').onmouseout(function(){
$('.viewport').css('background-image', 'url(' + empty + ')');
});
}
}
:hoverw3schools.com/cssref/sel_hover.asp