user2644833
user2644833

Reputation:

Use variable name fadeIn and Prepend

I want to prepend this variable "logText" and make it fade in at the same time.

var logText = today + ":" + " " + document.getElementById("textBox").value + '<br>\n';
$("#logContent").prepend(logText);

Here is what I got but it doesn't work.

var logText = today + ":" + " " + document.getElementById("textBox").value + '<br>\n';
$("#logContent").prepend($(logText).fadeIn('slow'));

Upvotes: 1

Views: 102

Answers (2)

Andreas
Andreas

Reputation: 21911

$("<p>" + today + ": " + $("#textBox").val() + "</p>")  // new DOM Node
              .css("display", "none")    // hide it
              .prependTo("#logContent")  // prepend it to #logContent
              .fadeIn("slow");           // fade it in slowly

fiddle

Upvotes: 2

Unicornist
Unicornist

Reputation: 932

$("#logContent").prepend(today + ": " + $("#textBox").val() + '<br>').fadeIn('slow');

Upvotes: 0

Related Questions