Reputation: 2274
I tried inserting some html and at the same time giving it an effect of fadeIn. This is how I attempted to achieve it, but it failed:
<html>
<head>
<title></title>
<script src="Jquery.js">
</script>
</head>
<body>
<style type="text/css">
.container{
background-color: red;
}
</style>
<div class="container"><img src="001.jpg" alt="sasuke"></div>
<script type="text/javascript">
(function(){
$("<p>lorem Ipsum blah blah </p>").insertAfter("img").fadeIn(1500);
})();
</script>
</body>
</html>
Upvotes: 2
Views: 4224
Reputation: 1
Try this;
(function(){
$("<p>Fade in text </p>").hide().fadeIn(1500).insertAfter("img");
})();
Upvotes: 0
Reputation: 626
Create the element hidden when you add it to the DOM, then fade it in:
(function(){
var paragraph = $("<p>");
paragraph.text("lorem Ipsum blah blah");
paragraph.hide();
paragraph.insertAfter("img");
paragraph.fadeIn(1500);
})();
Upvotes: 10
Reputation: 5399
Try this:
(function(){
$("<p style="display:none;">lorem Ipsum blah blah </p>").insertAfter("img").fadeIn(1500);
})();
Upvotes: 0