Having a little issue with a simple jQuery fadeOut?
I have a simple ID I want to fadeOut with jQuery after a button. However, when clicking on the respected button it doesn't work and nothing happens. Heres how I get JS开发者_JAVA百科 file from different location like this:
<script src="http://myflashpics.com/v2/jQuery.js"></script>
<script src="http://myflashpics.com/v2/actions.js"></script>
Here's my action in my actions.js file:
$(document).ready(function() {
$(function() {
$(".profileLink").click(function() {
$("#right_bar_content").fadeOut("slow");
});
});
});
Here's some other HTML assosiated with it:
<img src="http://myflashpics.com/get_image.php?short_string=avqc&size=thumbnail" class="profileLink" />
<div id="right_bar_wrapper" id="right_bar_content">content here</div>
Please help!
CoultonFirst of all, you shouldn't have two separate ids for your div. Get rid of the right_bar_wrapper
id and merge the CSS for the two ids.
Second, $(
is just short-hand for $(document).ready
; it shouldn't be nested. Remove one or the other.
$(document).ready(function() {
$(".profileLink").click(function() {
$("#right_bar_content").fadeOut("slow");
});
});
You are wrapping your code with DOM ready twice. This shouldn't be an error, but it is not good practice.
Your problem is your div
has two id
attributes, and the first one being parsed is used in the DOM. I believe a HTML attribute may only ever be used once on the same element.
Get rid of the first id
attribute.
Your element can't have two IDs.
精彩评论