Why Doesn't This Jquery Code Work?
I have this code in my application.js file, but it doesn't seem to work: $('#video_div img').click(function() { $('div.embed').toggle(); }); Here's the HTML my browser sees
Solution 1:
Is your code getting called? Do you need to do this?
$(document).ready(function () {
$("#video_div img").click(function() {
$("div.embed").toggle();
});
});
Solution 2:
It's working for me. Are you sure you have jQuery loaded. Make sure your jquery.js is placed just before the closing body tag </body>
<scriptsrc="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.min.js"type="text/javascript"></script>
Check working example at http://jsfiddle.net/Ey4YC/
You can also try your code like this if your want to keep your jquery.js in the header.
$(function() {
$("#video_div img").click(function() {
$("div.embed").toggle();
});
Solution 3:
my guess is Flash error. try the same code but this time when u click the image then resize browser.
recently my firefox and chrome oftenly not render youtube's vdo(the vdo just white like nothing load) but after i resize browser's window its appear.
Post a Comment for "Why Doesn't This Jquery Code Work?"