0

I'm working on a website for kids where they can play a simple Higher-Lower game with cards programmed in Jquery. I'm stuck on one particular part of my code though. I could fix it by writing a mass of double code, but there has to be a more efficient way to do it.

Edit: So the real question is, how do I call one function from another? Like a method.

I want to call my Kaartgenereren function from my Hoger() function.

function KaartGenereren() {...}

This is how I tried to call the function:

function Hoger(){
 oudekaart = kaartnummer;
 do{
 $.Kaartgenereren(); ...}while(...)}

I've also tried it without the $. and the (), but it led to no result.

I hope someone will be able to help me. Thanks in advance!

asked May 23, 2013 at 21:21
1
  • 1
    FYI Javascript is case-sensitive so if your function is called KartGenereren you should make sure the K and G are capitalized. Commented May 23, 2013 at 21:26

2 Answers 2

8

The correct way is

KaartGenereren();

but you have to fix a typo first

Kaartgenereren vs KaartGenereren
answered May 23, 2013 at 21:23
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks! That worked! I could've searched for hours to find that typo :)
Just use your javascript console. It would have told you right away that the function was not defined.
I did, and it said so indeed. But I assumed it would have something to do with functions not being recognised in other functions. (I'm very new to Jquery)
0
function Hoger(){
 oudekaart = kaartnummer;
 do {
 KaartGenereren();
 ...
 } while(...);
}
answered May 23, 2013 at 21:24

1 Comment

You missed the function name's typo when it's called.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.