View Single Post
Old 03-04-2013, 02:09 PM   PM User | #1
instaunt
New Coder

 
Join Date: Apr 2010
Posts: 92
Thanks: 4
Thanked 0 Times in 0 Posts
instaunt is an unknown quantity at this point
JQuery "trigger" won't work. What am I doing wrong?

Thank you everyone for your help with my jquery problem. I now have two working pieces of code:

Code:
<div id="myselector"><a href="/joke.php"><img src="/images/joke.gif" border="0" /></a></div>
<script>
$(document).ready(function() {
$("#myselector").mouseover(function() {window.location.href = $(this).find('a').attr('href');});
});
</script>
and:

Code:
<div id="myselector"><a href="/joke.php"><img src="/images/joke.gif" border="0" /></a></div>
<script>
$( document ).ready(function() {
$("#myselector").mouseover(function( event ) { 
 $(this).find('a')[0].click(); 
});
});
</script>
Which fires the /joke.php link when the image is hovered over. But this is going to be a sitewide code for various old elements. Some, are called by javascript. And this:

Code:
<div id="myselector"><script type="text/javascript" src="/archive/humour.js"></script></div>
<script>
$( document ).ready(function() {
$("#myselector").mouseover(function( event ) { 
 $(this).find('a')[0].click(); 
});
});
</script>
does not work. The humour.js file returns a random jpg/gif that has an <a href> link. How do I get the href link in the javascript file to fire on hover?

Thanks again
__________________
I've been making animations for my daughter. Tell me what you think!

Pickles and the Bully
Where are you Pickles!?!

Last edited by instaunt; 03-05-2013 at 01:12 AM..
instaunt is offline   Reply With Quote