0

I realise this is a bit of an odd question as it's slightly contradictory but I'd like to be able to hide text that doesn't fit into a div. That much is easy but then I need to take the text that is hidden and store it in a js variable so that i can make it visible on a button click so for example:

<html>
<body>
      <div style = "height:10px;width:50px;word-wrap:break-word;overflow:hidden">
            <p id = "text">Text that is too big for div</p>
      </div>
</body>
</html>

JS

var overflow = /*equates to overflow of div*/
$(document).click(function(){
document.getElementById('text').innerHTML = overflow
})

Something like that.

Derek 朕會功夫
  • 92,235
  • 44
  • 185
  • 247
CHeffernan087
  • 205
  • 1
  • 3
  • 15

1 Answers1

0

Why not just get rid of the overflow: hidden property on click?

var content = document.getElementById('content'),
    button = document.getElementById('unhide');

button.addEventListener('click', function(){
    content.style.overflow = 'visible';
});
<button id="unhide" type="button">Unhide</button>
<div id="content" style="height:35px;width:100px;word-wrap:break-word;overflow:hidden">
    <p>Text that is too big for div. Text that is too big for div. 
       Text that is too big for div. Text that is too big for div. </p>
</div>
rnevius
  • 26,578
  • 10
  • 58
  • 86
  • No. I need to replace the current visible text with the text that is not visible. its a cosmetic thing. Thanks anyway – CHeffernan087 Sep 01 '15 at 17:50
  • That's not what you said in your question at all. Please edit your question to make it clear what you actually want. – rnevius Sep 01 '15 at 17:59