0

i am trying it on jsfiddle...............i dont know why its not running...........someone help

html section
<html>
    <body>
        <div>The Answer is: </div>
        <div class='answer'></div>
    </body>`enter code here`
</html>


js section
function writeAnswer(answer) { // helper function for output
    $('div.answer').append($('<div>').text(answer));
}

function writedemo() {
    var answer="hello";
    writeAnswer(answer);

    }

}

writedemo();
1
  • 1
    How about a link to the fiddle so we can make sure you linked in the libraries correctly, used onLoad() correctly, etc Commented Aug 1, 2012 at 6:18

2 Answers 2

2

working demo http://jsfiddle.net/zJ3yk/

because you got extra }

rest should help the needs :)

code

function writeAnswer(answer) { // helper function for output
    $('div.answer').append($('<div>').text(answer));
}

function writedemo() {
    var answer="hello";
    writeAnswer(answer);

    }
//} <===== this is the culprit and rest demo gives you idea. 

writedemo();​
Sign up to request clarification or add additional context in comments.

Comments

0

Check the following jsfiddle. you can find working js.

http://jsfiddle.net/shivkant/HQyZe/8/

Comments

Your Answer

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.