I have a problem and the problem is greater because it's seen as a duplicate by some people here (of: How do I copy to the clipboard in JavaScript?).
I have
<div class="ce">
<div class="lotB">9</div>
<div class="lotB">3</div>
<div class="lotB">28</div> == $0
</div>
I want these inner text in form of 9 3 28
, so I set up a string which equals 9 3 28
It's done like that:
var x = document.getElementsByClassName("lotB");
var count = 0;
var text = "";
for (var i = 0; i < x.length && count<3; i++) {
var nums = x[i].textContent;
text = text + nums.toString() + " ";
count++;
}
Then text = "9 3 28"
Now my question, how can I directly copy the value of text
to my clipboard such that I can post it somewhere else?