开发者

jQuery script fails in IE and Opera

开发者 https://www.devze.com 2023-01-16 03:53 出处:网络
http://dev.mindboiler.lv/ (you\'ll be taken to intro page, just click on logo to get into real site) This is website I\'m cu开发者_如何转开发rrently working on. You can change the language to English

http://dev.mindboiler.lv/ (you'll be taken to intro page, just click on logo to get into real site)

This is website I'm cu开发者_如何转开发rrently working on. You can change the language to English to understand it a little better, but anyways, it's full of dummy text.

There are these Read more links which, when clicked, execute the following jQuery:

$('.content-item .readmore').toggle(function() {
    parent = $(this).parent();
    $(parent).children('div.next').fadeIn();
    $(this).html("Read less »");
}, function() {
    parent = $(this).parent();
    $(parent).children('div.next').fadeOut();
    $(this).html("Read more »");
});

Firefox, Safari, Chrome works like a charm, but Internet Explorer (all versions) and Opera doesn't want to execute it properly.

Any solutions for this to work in IE and Opera?

P.S. Not a JavaScript/jQuery guru, therefore the script looks like crap.

Thanks in advance!


It appears as though your <div class="next"> is a sibling to your <div class="content-item"> so why even bother with the parent() function.

Simplify it to this and see if it works:

$('.content-item .readmore').toggle(function() {        
    $(this).next().fadeIn();
    $(this).html("Read less &raquo;");
}, function() {
    $(this).next().fadeOut();
    $(this).html("Read more &raquo;");
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号