Streaming live at 10am (PST)

Onclick find children inside of div


#1

Hey guys,

So right now using the method below, I have to have the “.link” text nested inside of one of the two buttons in order for it to be attributed to the “#link”.

Is there a way to be able to click either btn1 or btn2 and have the function run (where the #link text takes the attributes of “.link”)?

Can I call an unrelated div that nests the .link class?

 <script>
    $(".btn1, .btn2").on("click", function() {
   	   var x = $(this).find(".link").text();
       $("#link").attr("href", x);
    });

EDIT:

If anyone needs the solution to the problem see the Stack Overflow thread here: https://stackoverflow.com/questions/48845966/finding-attributes-onclick-from-unrelated-div