Reputation: 14153
I'm trying to call a function into another function to get rid of some redundant code. The 'test' function is a standard piece of repetitive code, so I don't want to keep writing it out along with the custom animation.
(function test() {
do this
});
/* =========================Standard code========================= */
$(function () {
$('#div').click(EXECUTE THE 'TEST' FUNCTION HERE AND THEN...function() {
$('#timeline').stop().animate({
left : "+=500px"
});
});
});
Here is the solution thanks to the kind guys below:
function test() {
do this
}
/* =========================Standard code========================= */
$(function () {
$('#div').click(function() {
test();
$('#timeline').stop().animate({
left : "+=500px"
});
});
Upvotes: 0
Views: 82
Reputation: 682
why you are using round braces around the test() function?
Can you try with an ALERT box in test() function?
Upvotes: 1
Reputation: 3139
Is there anything wrong with:
$(function () {
$('#div').click(function() {
test();
$('#timeline').stop().animate({
left : "+=500px"
});
});
??
Upvotes: 2
Reputation: 4316
You would put your call to test()
above the $('#timeline')....
line.
Upvotes: 1