简体   繁体   中英

why jquery code not running in jsfiddle

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();

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();​

Check the following jsfiddle. you can find working js.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM