php - How I take value from menu bar using Javascript -
I am very new to javascript, but I want to solve this problem.
My code is:
Javascript:
function win (anchor) {var value = anchor.getAttribute ('value'); Var html = anchor.inner html; Document.write (value); Document.write (html); }
HTML:
& lt; Ul id = "nav" & gt; & Lt; Li & gt; & Lt; A href = "# 1" onclick = "victory (this)" & gt; Quantitative & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "# 2" onclick = "win (this)" & gt; Cause & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "# 3" onclick = "victory (this)" & gt; English & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "# 4" onclic = "victory (this)" & gt; Common knowledge: & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "# 5" onclick = "win (this)" & gt; Computers & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt;
And I want to know that to get the javascript, I get the value of the menu bar option which I recently clicked on.
Whenever I click on the menu I get value in the variable.
I created this example -
function win (anchor) {Var html = anchor.inner html; Console.log (html); }
who works in this Bela -
Comments
Post a Comment