javascript get clicked link id and compare it with a string -
I am new to javascript, please help me please!
I have these four links: And I have a div, element with AP and form. P ID: id = "editHeader". What I want to do, to change P value, was clicked on the basis of that link. So I want to compare the ID value of the link clicked with the string: My function is such, but it does not work: You should use the # as href and onclick events. This way. Otherwise your javascript is correct. The person working here is There will be a good effect for your anchor tag, href = "# editHeader" so that the window is trying to change the type of
& lt; An id = "user name" href = "javascript: showEditTextBox (this.id)" & gt; & Lt; / A & gt; & Lt; An id = "business" href = "javascript: showEditTextBox (this.id)" & gt; & Lt; / A & gt; & Lt; A id = "country" href = "javascript: showEditTextBox (this.id)" & gt; & Lt; / A & gt; & Lt; An id = "industry" href = "javascript: showEditTextBox (this.id)" & gt; & Lt; / A & gt;
function showEditTextBox ( Id) {if (id == "userName") document.getElementById ("editHeader"). innerHTML = 'Change User Name'; Else if (id == "occupation") document.getElementById ("editHeader"). innerHTML = 'change business'; else if (id == "country") document.getElementById ("editHeader"). innerHTML = 'change country'; else if (id == "industry") document.getElementById ("editHeader"). innerHTML = 'Change Industry'; }
& lt; an id = "industry" href = "# edit headers" onclick = "showEditTextBox (this.id)" & gt; Industry & lt; / A & gt;
Comments
Post a Comment