jQuery .slideDown() issue in IE
Posted: Tue Oct 25, 2011 9:43 pm
Hello,
I am new to JavaScript and jQuery.
Here is the HTML:
Here is the JavaScript:
When a user clicks the link it will replace the link text with a loading gif and once the data loads the gif is replaced with "Close" and the section right before slides down with the data.
It works fine in every browser except IE8 and below where it shows the loading gif and and says there is an error in the script and never loads/shows the data.
How can I fix it?
Also if you have any suggestions on how to clean up the code, that would be great.
Thanks.
I am new to JavaScript and jQuery.
Here is the HTML:
Code: Select all
<section>
<h2></h2>
<section></section>
<a href="">View</a>
</section>Code: Select all
$(document).ready(function(){
$('.content').click(function(){
url = $(this).attr('href');
content = $(this).prev().html();
if(content === '') {
$(this).prev().load(url,function(){
$(this).slideDown(400);
$(this).next().html('Close');
});
} else {
$(this).prev().slideUp(400,function(){
$(this).html('');
});
}
if($(this).html() === 'View') {
$(this).html('<img src="img/loading.gif">');
} else {
$(this).html('View');
}
return false;
});
$('.close').click(function(){
$(this).prev().slideUp(400,function(){
$(this).html('');
});
$(this).html('View').attr('class','button content');
return false;
});
});It works fine in every browser except IE8 and below where it shows the loading gif and and says there is an error in the script and never loads/shows the data.
How can I fix it?
Also if you have any suggestions on how to clean up the code, that would be great.
Thanks.