'Build A Random Quote Machine' Help

'Build A Random Quote Machine' Help
0

#1

Hi,

I am having trouble with finishing my Twitter button. I need to select the displayed on screen quote that has the CSS properties display=block and select the text in that

tag. It may be easier to understand from my CodePen: http://codepen.io/Saudade/pen/bgwmNa

Any help would be much appreciated as I have been pulling my hair out for the best part of a week!


#2

Are you talking about the Twitter button? The easiest way to know the current quote is to store it in a global variable when it is created/selected, then access that variable from the function that is fired when the user clicks the Twitter button.
Reading the text from the page before tweeting it out is doable (http://www.w3schools.com/jsref/prop_html_innerhtml.asp), but it seems unnecessarily complicated.


#3
var textToTweet = [...document.querySelectorAll('.quotes')]
                  .filter(e => e.style.display === 'block')[0]
                  .textContent