tags:

views:

24

answers:

1

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 currently 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!

+1  A: 

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;");
});
Chris Conway
Since `Read more` link is the last child element of `.content-item` it won't work with `.next()`, but yeah, changing it to `.prev()` did the trick! Thanks for pointing in the right direction, accepted!
Tom