0
Here is the code:
jQuery(function($) {
$('a.panel').click(function() {
console.log($($(this).attr('href')));
var $target = $($(this).attr('href'));
$target.show().css({
left: -($target.width())
}).animate({
left: 0
}, 500);
});
});
#right {
position: relative;
float: left;
margin: 0 5px 0 0;
border: 1px solid black;
width: 200px;
height: 200px;
overflow: hidden;
}
div.panel {
position: absolute;
height: 100%;
width: 100%;
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#target1" class="panel">Target 1</a><br/>
<div id="right">
<div class="panel" id="target1" style="background:blue">
<script>
var tmp = new Array("1","2","3","4");
var myvar;
var i = 0;
var timer = setInterval(function() {
if(tmp.length) {
var p= tmp.shift();
console.log(p);
document.getElementById("right").innerHTML = p;
} else {
clearInterval(timer);
}
}, 5000);
</script>
</div>
</div>
My goal is whenever a number appears the background changes color...
So far I’ve only found functions that do it separately.
I’ve tried to change the click
but to no avail.
You can use jQuery?
– Felipe Avelar
@Ana, consider putting the code in the question and not giving a link with it
– CesarMiguel
@Felipeavelar Her code already uses jQuery.
– bfavaretto