Home Ask Login Register

Developers Planet

Your answer is one click away!

Fazy January 2017

How can I add a fade when I change the content of a div?

At the moment I have the following script...

    $(document).ready(function () {
        $('.manual').click(function () {
        $('.excercise').click(function () {
        $('.electro').click(function () {
        $('.acupuncture').click(function () {
        $('.hydrotherapy').click(function () {
        $('.sports').click(function () {

If I take one section to explain...

        $('.sports').click(function () {

So If I click on a div with the class 'sports' it will then... Remove anything in the div with a class 'description' and replace with the contents of a div with the id 'sports'. Then it will take the div with the class 'descriptiveImage' and replace it with the contents of the div witht he id of 'sportsImage'.

I'm sure most of you will recognize this as a rather generic replace script.

What I'd like to do is change the script so that the existing content of the div .descripti


inorganik January 2017

Use the fadeOut() on-complete function argument:

$('.description').fadeOut(400, function() {
$('.descriptiveImage').fadeOut(400, function() {

nikelyn January 2017

maybe as the following:



Post Status

Asked in January 2017
Viewed 2,720 times
Voted 13
Answered 2 times


Leave an answer

Quote of the day: live life