I want to add a new attribute to my HTML dynamically, but I cannot figure out how to do this:
I have code on Facebook as a button code, where I want to add the attribute "data-url" if the Url property is specified in my model.
I tried a couple of things, but now my code looks like this:
<a href="https://twitter.com/share" class="twitter-share-button" @if (!string.IsNullOrEmpty(Model.Url)) { data-url="@Model.Url" } data-text="@Model.TweetText" data-count="vertical" data-via="avalaxy">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
This does not work. So how do I do this?
source share