Guest User

Untitled

a guest
Feb 25th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. <div class='square' id='sq12'><p class='text'><br/>"Text I want to fetch"</p></div>
  2.  
  3. Cannot read property 'getElementsByClassName' of null
  4.  
  5. $('body').on('click', '.square', function(e)
  6. {
  7. var fetchedText = document.getElementById(e.target.id).getElementsByClassName('text')[0].innerHTML;
  8.  
  9. alert(fetchedText);
  10.  
  11. });
Add Comment
Please, Sign In to add comment