Javascript doing something strange? works in IE but not firefox? -


I am trying to create an element, click and when the element is clicked, but it does nothing is?

Why do the hide () function do nothing?

  & lt; Script type = "text / javascript" & gt; Function show () {var a = document.getElementById ('foo'); Var B = document.createElement ("div"); B.setAttribute ('id', 'bar'); B. SetActivate ('onclick', 'hide ()'); A.appendChild (b); B.innerHTML = 'Text Content'; B.onclick = function () {hide (); }; } Hide function () {var x = document.getElementById ('foo'); Var z = document.getElementById ('bar'); X.removeChild (z); } & Lt; / Script & gt; & Lt; Div id = "foo" onclick = "show ()" & gt; Click me & lt; / Div & gt;    

Add b.onclick = function () {hide ();}

Comments