Random quote machine!

Hey guys, i need a little help. If you open my code pen, you will se that both my buttons (generate quote, and share quote), they both generate a quote. How do i select a specific button in javascript? one should generate it, and other should share it on twitter. Any clues?

here is my pen:

You could select a button based on ID.



1 Like

well yes, but if you look my code, you can see that i have UL classes, and i, e subclasses…how can i change from there? i dont want to change everything to <button :confused:

The code below is causing both anchors to change the quote,

  $(".btn").on("click", function() {

There are a couple of ways to make one anchor generate a new quote and the other tweet the quote.
One way is to do something similar to what @Quickz suggested and add an unique ID to each anchor. Then, you would have create a click event handler for each id (one to generate the quote and the other tweet the quote).

btw, if i try to <button, and if i try to put some of my bootstrap icons in it, it doesnt work (twitter icon is not showing)btnbtn

BTW - Looking at your latest screenshot, there is no such element as e. I think you meant to put an i element instead of an e element.

yes i know that, and thats what i am trying to change, but i try to keep my UL and Li classes, instead of changing everything to <button, but i dont know where can i put an ID, so i can sepereate them. feeling lost a bit

ah ok i solved it, thank you guys for helping.

I did not say anything about adding a button element.