How to replace data-text with javascript variable


#1

how to replace data-text content if we have javascript variable from text area?
example :

<form>                            
    <div class="input-control textarea">
             <textarea id='text1' placeholder="Enter Your Tweet"></textarea>
    </div>
</form>

<script type="text/javascript">
    var tweet = document.getElementById('text1').value;
</script>

<a href="https://twitter.com/share" class="twitter-share-button" data-text="costum data-text with javascript variable" data-lang="en">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

I would like to change data-text=“costum data-text with javascript variable” with var tweet


#2