Hello all,
I'm trying to get a calculation to appear in a DIV, in HTML. The calculation shows fine with the HTML, but my problem is that the result is showing straight away. I want it to display 5 seconds after the calculation is done (it's done in jquery).

What do I need to change to get this working? I looked on google and it said to use delay but it isn't working.

$("#result").show().delay(5000).html("<p>Your BMI result is:"+ ++bmi + "</p>");

By the way, if your wondering why I use show, it's because the div is hidden using jquery using hide().

I would appreciate it if someone tells me how to make the 5 second delay.

Cheers,

You have the right idea, but your sequence is off:

$("#result").hide();
$("#result").html("<p>Your BMI result is:</p>").delay(5000).fadeIn();​

You can see it in action here: http://jsfiddle.net/kc5T9/8/

Also if you want it to fade in a little slower you can use

fadeIn(500);

Hope this helps.

Hi Dschuett,
I managed to get the problem solved using a slightly different approach

$("#result").html("<p>Your BMI result is:"+ ++bmi + "</p>");
     $("#result").delay(5000).show(0);

Thanks for your help :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.