Here's what I'm hoping to do: I have a list of menu items when clicking on one of these items If so, then I need a Javascript function to move text in that list item and put it in a different place on the page.
Here's my JSField:
function settext () {document.getElementById ("selected"). InnerHTML = this.innerHTML; }; I do not have much information about javascript, so I'm sure the problem is simple.
In addition, if there is a similar question on the stack overflow, Send a link to this and I will remove this question.
You have to pass the element to the function ... so that you know which & Lt; A & gt; You clicked the tag. Then in your HTML, you add this as a function parameter & lt; A href = "#" onclic = "set text (this);" & Gt; and in your JavaScript ... (e) In this case, now that element is referenced. function setText (e) {document.getElementById ('selected'). InnerHTML = e.innerHTML; }
Here it is using Jquery ... just to show how compact it is ...
& lt; A href = "#" & gt; .
$ ('a'). Click (function () {$ ('# selected') .HTML ($ (this) HTML ());};
No comments:
Post a Comment