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: javascript - Finding attributes .on("click") from unrelated div - Stack Overflow