Whats wrong with my code? (jQuery + HTML)

Posted by Art Zeeman on Stack Overflow See other posts from Stack Overflow or by Art Zeeman
Published on 2012-10-18T16:47:41Z Indexed on 2012/10/18 17:01 UTC
Read the original article Hit count: 142

Filed under:
|
|

I'm trying to open a link as soon as you open the page (by forcing a click) with jQuery, but it doesn't work.

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
    $('a.bla').click(function(){
    window.open(this.href);
    return false;
    });
});
</script>   
</head>
<body>
<a href="url-to-open.php" target="_blank" class='bla'><img src="pic.png" alt="" style="border:none;" /></a>
</body>
</html>

I have no clue what's wrong. I hope someone of you knows how to fix this.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html