First, why do you want to copy the contents of one <span> to another on the same page? Because, honestly, that seems like an odd thing to do. What are you trying to accomplish? Perhaps, there's a better/easier way.
Second, there's no macro which will return the text from an element, so, at the moment, you can't without dipping into JavaScript. The requisite JavaScript is easy enough, if you really need to do something like that. For example:
<span id="copy-source">Text to copy</span>
<span id="copy-dest"></span>
<<click "Copy">>
<<script>>$("#copy-dest").html($("#copy-source").html())<</script>>
<</click>>
That will copy the contents of #copy-source to #copy-dest, including markup (which I assume you'd want).
First, why do you want to copy the contents of one <span> to another on the same page? Because, honestly, that seems like an odd thing to do. What are you trying to accomplish? Perhaps, there's a better/easier way.
Second, there's no macro which will return the text from an element, so, at the moment, you can't without dipping into JavaScript. The requisite JavaScript is easy enough, if you really need to do something like that. For example:
<span id="copy-source">Text to copy</span>
<span id="copy-dest"></span>
<<click "Copy">>
<<script>>$("#copy-dest").html($("#copy-source").html())<</script>>
<</click>>
That will copy the contents of #copy-source to #copy-dest, including markup (which I assume you'd want).
Hmm. In that case. In the given code, the source content will replace any existing destination content each time. If that's the behavior you need, then carry on. If, on the other hand, you need the source content added to any existing content in the destination, then you'll want to change the code slightly. For example, the following will append to the source to the destination:
Hmm. In that case. In the given code, the source content will replace any existing destination content each time. If that's the behavior you need, then carry on. If, on the other hand, you need the source content added to any existing content in the destination, then you'll want to change the code slightly. For example, the following will append to the source to the destination:
Comments
You don't need the <span class="click"> for the above to work:
Well ok, but it just doesnt work anyway. You didnt answer the question: what should I write into replace for it to work?
Second, there's no macro which will return the text from an element, so, at the moment, you can't without dipping into JavaScript. The requisite JavaScript is easy enough, if you really need to do something like that. For example: That will copy the contents of #copy-source to #copy-dest, including markup (which I assume you'd want).
Oh yes thats awesome. Thanks a lot. Well, it basically comes from my previous question about creating many buttons on one page (twinery.org/forum/discussion/3066/execute-run-functions-after-a-press-on-the-same-page#latest), and I think this solves the problem. Thanks again!
I actually need both, but I was ok doing the rest with <replace> macro.
But since you proposed a variant, I have a question about it: your last example would just result in this:
or in this:
?
EDIT: well, I guess I can test it myself. Thanks for your help.
Given the following setup: After one copy, you'd have this: And with the appending version, after another copy, you'd have this: