I have a repeater with items that each contain a video. This video name is dynamic and i embed into flowplayer from the ID in a span tag. My problem is i cant come up with logic that will only grab the selected span ID as each of the spans have the same parent ID, so it always grabs the first one.
我有一个转发器,每个项目都包含一个视频。此视频名称是动态的,我从span标记中的ID嵌入到flowplayer中。我的问题是我不能提出只捕获所选跨度ID的逻辑,因为每个跨度具有相同的父ID,所以它总是抓住第一个。
<asp:Repeater ID="rep_WebinarsCompleted" runat="server" OnItemDataBound="rep_WebinarsCompleted_ItemDataBound">
<ItemTemplate>
<a href="" id="overlay-triggers" name="overlay-triggers" runat="server">
<span id='<%# DataBinder.Eval(Container.DataItem, "VideoFileName")%>'>View</span>
</a>
</ItemTemplate>
</asp:Repeater>
I retrieve the span ID(video file name) from: var i = $("#overlay-triggers span").attr("id"),
我从以下位置检索范围ID(视频文件名):var i = $(“#overlay-triggers span”)。attr(“id”),
<script type="text/javascript">
$(function () {
$("#overlay-triggers").overlay(
onBeforeLoad: function () {
var i = $("#overlay-triggers span").attr("id"),
alert(i);
},
});
});
</script>
1 个解决方案
#1
1
You could add an onclick
to each of the spans.
您可以为每个跨度添加一个onclick。
So something like this:
所以这样的事情:
<span onclick="spanClicked(this.id);" id='<%# DataBinder.Eval(Container.DataItem, "VideoFileName")%>'>View</span>
The this.id
in the function call passes the span's (this
) ID (id
) property into the function. And have a function to call:
函数调用中的this.id将span的(this)ID(id)属性传递给函数。并具有调用功能:
function spanClicked(id){
alert(id);
}
#1
1
You could add an onclick
to each of the spans.
您可以为每个跨度添加一个onclick。
So something like this:
所以这样的事情:
<span onclick="spanClicked(this.id);" id='<%# DataBinder.Eval(Container.DataItem, "VideoFileName")%>'>View</span>
The this.id
in the function call passes the span's (this
) ID (id
) property into the function. And have a function to call:
函数调用中的this.id将span的(this)ID(id)属性传递给函数。并具有调用功能:
function spanClicked(id){
alert(id);
}