I have code:
<div class="text">
<span class="word">
Hello
<span/>
<span class="word">
world!
<span/>
<div/>
I want to copy this text into line "Hello world!"
But when I copy it, it looks like:
Hello
world!
I have code:
<div class="text">
<span class="word">
Hello
<span/>
<span class="word">
world!
<span/>
<div/>
I want to copy this text into line "Hello world!"
But when I copy it, it looks like:
Hello
world!
3
Answers
After fixing your end tags, you likely did the first, but need to use the second method
jQuery if you want it
It is not clear, whether you want to copy the text from all spans on the web page, or if your HTML code is only a part of a bigger webpage and you only want to copy the texts from spans with the
word
class.If you want to copy only the text from spans with the
word
class, you can use the following code which:word
class,Might be simpler approach