Why cant I work out with this function in my js:
error: ReferenceError: new_tweet is not defined
function new_tweet(){
alert("here i am");
}
function add_div(){
mydiv = document.getElementById("new_twt");
mydiv.innerHTML="<input type='button' value='You have new conversations' onclick=new_tweet();>";
}
The problem is probably that you are doing this in some kind of load handler, which means that
new_tweetis not global and therefore not available when you click the button. Try definingnew_tweetin a global scope.Here is a demonstration: http://jsfiddle.net/DUbc3/