I’m trying to show and hide elements, sort of like a slideshow, but I want to control how long each individual element is shown for. I don’t want the elements to fade in or out either, but just appear immediately after the previous element has been hidden. Try to picture credits after a tv show or something like that, but each element can be individually timed. How can I achieve this with what I have so far?
(I’m having trouble using .delay – it’s not doing what I’ve told it to do in the js)
<html>
<title>Untitled</title>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#one').delay(1000).show(0, function() { });
$('#one').delay(3000).hide(0, function() { });
$('#two').delay(3000).show(0, function() { });
$('#two').delay(4000).hide(0, function() { });
$('#three').delay(4000).show(0, function() { });
$('#three').delay(6000).hide(0, function() { });
$('#four').delay(6000).show(0, function() { });
$('#four').delay(6000).hide(0, function() { });
});
</script>
<style type="text/css" media="screen">
body {
margin: 0px;
padding: 0px;
font-family: arial, sans-serif;
padding: 0px;
background: #fff;
}
#one, #two, #three, #four, #five, #six {
position: absolute;
top: 50px;
left: 50px;
display: none;
font-size: 48px;
font-weight: bold;
font-family: arial, sans-serif;
color: #111;
}
</style>
</head>
<body>
<p id="one">this is text #1</p>
<p id="two">this is text #2</p>
<p id="three">this is text #3</p>
<p id="four">this is text #4</p>
<p id="five">this is text #5</p>
<p id="six">this is text #6</p>
</body>
</html>
I had to guess at exactly what you wanted, but I think this is what you’re looking for:
You can see it working at http://jsfiddle.net/3XnGR/