I have a chunk of code like this:
$(".ani-search").toggle(
function(){
$("#header .logo a").animate({
marginLeft: "-=30px",
marginLeft: "-=60px",
marginLeft: "-=90px"
});
},
function(){
$("#header .logo a").animate({
marginLeft: "-=60px",
marginLeft: "-=30px",
marginLeft: "0px"
})
}
);
When I run the corresponding html page, I do not get any VALID toggle response. What happens is as soon as I open the page the image with class "ani-search" blinks once and vanishes thats it, I do not get to toggle anything? Why is this happening?
Similarly here is another test code"
<p>Hello world</p>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.10.0.js"><\/script>')</script>
<script>
$("p").toggle(
function(){
alert("Cliclk 1");
},
function(){
alert("Click 2");
}
);
</script>
same thing happens here, as soon as I load the page in my browser, the text "Hello world" blinks once and I get the alert box with message with "Click 2". Thats it.
Why cant I toggle here?