I want to display whether a twitch username in my anchor link is online or offline. The problem is that I will have multiple usernames on the website, and my code only works for the first one.
var tnick = $('#ltwitch').data('tnick');
$.getJSON("https://api.twitch.tv/kraken/streams/"+tnick+".json?callback=?", function(c) {
if (c.stream == null) {
$("#live").html("Offline");
} else {
$("#live").html("Online");
}
});
This is my html: (can be changed)
<a id="ltwitch" href="#" data-tnick="name1">x</a> (<span id="live">...</span>)
<a id="ltwitch" href="#" data-tnick="name2">x</a> (<span id="live">...</span>)
Any help will be appreciated. Thanks.