I am trying to use the jQuery .removeData and .data functions to change the values in the tweet button. I am trying to modify the data-text attribute and I cannot get it to work.
Also tried:
$("#twitter").removeData();
$("#twitter").removeData(text);
2.Pull from my array to with:
$("#twitter").data(“text”, quotes[i])
All the jQuery in my JS works except those two. I am almost positive it has to do with my attempt at modifying the DOM data. I know a different solution as a work around for this, but really want to understand the flaw in my logic.
I welcome any comment that can point me in the correct direction.
The issue with your program is something else. I think you’re using an iframe for twitter. So after the iframe is initialized with your first hardcoded data-text, you can’t update it anymore.
Why not just call twitter with something like this?
<a href="https://twitter.com/intent/tweet?text=your text goes here - www.yourwebsite.com">
Tweet me</a>