我有一个用于图像的 jQuery 滑块,在 HTML 版本中它可以正常工作,但在 asp.net datalist 中则不行。我可以为基于表的结构添加任何兼容的 jQuery 吗?实际上,ASP.NET datalist 在浏览器中围绕图像呈现TABLE、TR和TD标签,这给实现 jQuery 带来了问题。
数据列表代码
<asp:DataList ID="dlphoto" runat="server" BorderStyle="Solid" BorderWidth="0px" RepeatColumns="3" RepeatDirection="Horizontal">
<ItemTemplate>
<asp:Image ID="Image" runat="server" CssClass="thumbnail"
ImageUrl='<%# "~/Photos/RoomPhotos/" + Eval("Photourl") %>' />
</ItemTemplate>
</asp:DataList>
渲染后datalist代码如下
<table>
<tbody>
<tr>
<td><img src="../Photos/RoomPhotos/337653939_1.jpg" id="ctl01"></td>
<td><img src="../Photos/RoomPhotos/1167094800_4.jpg" id="ctl02"></td>
<td><img src="../Photos/RoomPhotos/1901620528_profile1.jpg" id="ctl03"></td>
</tr>
<tr>
<td><img src="../Photos/RoomPhotos/337653939_1.jpg" id="ctl04"></td>
<td><img src="../Photos/RoomPhotos/1167094800_4.jpg" id="ctl05"></td>
<td><img src="../Photos/RoomPhotos/1901620528_profile1.jpg" id="ctl06"></td>
</tr>
</tbody>
</table>
我想在数据列表上应用的 JQuery 滑块
<div id="slides">
<img src="http://4hdwall.com/wp-content/uploads/2012/04/Valentines-Day-for-mobile-150x150.jpg">
<img src="http://4hdwall.com/wp-content/uploads/2012/04/ws_Purple_Spring_and-class-nhe-dy-a-rhy-hn-150x150.jpg">
<img src="http://4hdwall.com/wp-content/uploads/2012/04/animal_mobile_wallpapers-150x150.jpg">
</div>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://slidesjs.com/js/jquery.slides.min.js"></script>
<script>
$(function() {
$('#slides').slidesjs({
width: 940,
height: 528
});
});
</script>