You should use .data()
for controlling data attributes. As Daniele states in that answer, you must also stop the event propogation on the a
element using preventDefault()
.
$('#twitterButton').click(function (e) {
$('#tweet').data('url',"https://www.google.com");
e.preventDefault();
});