Reputation: 345
i have an javascript script, but i can't put animate() in this.
<script language="javascript">
function appear(){
var elem = document.getElementById("about");
.animate({elem.setAttribute("style","z-index: 9999;")},800);
};
</script>
How i do this?
Upvotes: 1
Views: 48
Reputation: 44831
.animate()
is a method, not a stand-alone function. That means you can't call it by itself; you can only call it by operating on a jQuery object. So, .animate(...);
doesn't work, but $(....).animate(...);
can work. For example,
<script language="javascript">
function appear(){
$('#about').animate({zIndex: 9999},800);
};
</script>
Edited to fix the elem....
notation.
Additional explanation
Functions work like this:
function foo(bar) {
return bar + 1;
}
foo(1); // returns 2
That is, they are called out of context, by themselves.
Classes work like this (in JavaScript):
function MyObject() { }
MyObject.prototype.foo = function(bar) {
return bar + 1;
};
x = new MyObject();
x.foo(1); // returns 2
Upvotes: 3