如何使用从 twitch.tv 的 API 生成的 href 元素包装引导行?



所以我刚刚制作了一个免费代码训练营的JSON/JAVASCRIPT项目,该项目可以提取流媒体信息,例如其徽标,当前状态和显示名称。

我想将整个Bootstrap 3行包裹在具有流媒体链接的超链接中,因此您不必单击"显示状态"或"徽标"。

https://codepen.io/mmcphillips/pen/qjyzxv

目前,我的徽标和状态包裹在我从

中获得的超链接包装
   $.getJSON(url,function(status1){
if(status1.status===null){
  $("#liveStatus1").html("Offline");
}
else{
  $("#liveStatus1").html("<a href="+status1.url+">"+status1.status+"</a>");
  $("#drRow").html("<a href="+status1.url+"></a>");
}
console.log(status1.url);

}(;

我尝试使用代码示例中的第二个语句和status status 1.url?

中的整个行进行此操作。

假设$("#liveStatus1")是您的链接,而$('#drRow')是您的行,请尝试以下操作:

//when clicking the row, trigger the link inside
$('#drRow').click(function(){
    $("#liveStatus1").click();
});
//stop propagation of the event to prevent infinite recursion
$("#liveStatus1").click(function(e){
    e.stopPropagation();
});

让我知道

最新更新