|
JS: making invisible text (display:none) non-selectable
here's the problem i'm having. i've got a webpage that displays various stats for me. each stat is a link that toggles the visibility of a div right below it, which gives further info on that topic. every day i like to copy and paste my stats and save themn to a txt fie, but i don't need to save the details, just the main stats. however, when i highlight all of the text and Copy, it's copying the invisible text as well. i need to make the text non-selectable while it's invisible.
here's what i have:
<script type="text/javascript">
function toggle(obj) {
var el = document.getElementById(obj);
if ( el.style.display != 'none' ) {
el.style.display = 'none';
}
else {
el.style.display = 'block';
}
}
</script>
<a href="#" onClick="toggle('details1')" style="color:#000000; text-decoration:none">the numbers for this stat is: 1234</a><br><div id="details1" style="display:none">some info<br>more info<br>etc<br></div>
...
the numbers for this stat is: 567
...
so if i try to copy just the "the numbers for..." text, when i paste it, it pasts the detail;s info as well, even tho it's not even visible.
|