Hello! I can
t understand how to make a tweet button work correctly. Ive installed it using the Tweet Developer Documentation. And I
m trying to set a 'date-text' attribute by JQuery, but it doesnt work. Would you please review my CodePen and help me to find out what am I doing wrong?
Hello! I can
I’m not really sure how their widget works, but you can construct a URL to set your href to with the quote and author.
For example a tweet for hello world could be constructed with the URL below:
var url = https://twitter.com/intent/tweet?hashtags=hashtag&text=hello%20world
Note that spaces in the text should be replaced with %20 in urls
To set the href attribute, you can use
ve seen solution like this, with the url. But if I cant set the ‘text’ attribute, how can I change ‘href’ attribute?(( For some unknown reason I can`t control the ‘.twitter-share-button’ element by JQuery
I`ve decided to give up and make the button without the Tweet Button widget X))
<a> tag doesn’t have a text attribute, so that is why you are unable to control it using .attr(). For reference, the attributes for
<a> are listed here: https://www.w3schools.com/tags/tag_a.asp
If you define a tweet-url variable, a line like this should work to set the href attribute:
I mean ‘data-text’ attribute, that supposed to be, and I could set it in html, but not by jquery. But I`ve deleted it anyway, so no matter)
If you want to change the value of an attribute called ‘data-text’ for an element with class="somelass) with jQuery, you could write: