I've been trying for 3 days figure out why the attr() isn't working inside functions in Jquery. It may look like the question has already been answered but none of them is working for me.
I'm trying to change the data-text atribute from a tweet button to tweet the current text.
Here is my code:
$(".twitter-share-button").attr("data-text", "Hello World"); //Working
$("#change").on("click", function() {
$(".twitter-share-button").attr("data-text", "Hello Universe"); // Not working
});
Example in Jsfiddle: https://jsfiddle.net/ooneskbe/
cilckevent didn't fired.data-textsomewhere else.