如果类存在则评论的 jQuery 幻灯片
我在表格内动态创建了带有“helpfulreviews”类的评论。我想获取这些表格,并基本上隐藏除其中一个之外的所有表格,并在一段时间后使用 jQuery 自动滑入下一个表格
,这是三个评论,我希望一个显示并在大约 10 秒后滑入另一个表格,然后滑入第三篇评论,然后旋转回到开头。我简化了示例:
<table width="100%" border="1" cellspacing="0" cellpadding="0" class="helpfulreviews">
<tbody>
<tr>
<td>MY FIRST REVIEW GOES HERE<br>Terrible Product</td>
</tr>
</tbody>
</table>
<table width="100%" border="1" cellspacing="0" cellpadding="0" class="helpfulreviews">
<tbody>
<tr>
<td>MY SECOND REVIEW GOES HERE<br>Great Product you have here</td>
</tr>
</tbody>
</table>
<table width="100%" border="1" cellspacing="0" cellpadding="0" class="helpfulreviews">
<tbody>
<tr>
<td>MY THIRD REVIEW GOES HERE<br>This is an awesome product</td>
</tr>
</tbody>
</table>
其中一个表的完整代码:
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="helpfulreviews">
<tbody><tr>
<td width="1%"> </td>
<td width="99%">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="colors_descriptionbox">
<tbody><tr>
<td width="1px" valign="top"><img src="/v/vspfiles/templates/90/images/RBox_Border_Left_Top.gif"></td>
<td width="100%" valign="top" background="/v/vspfiles/templates/90/images/DBox_Border_Top.gif"><img src="/v/vspfiles/templates/90/images/clear1x1.gif" width="1" height="1"></td>
<td width="1px" valign="top"><img src="/v/vspfiles/templates/90/images/DBox_Border_Right_Top.gif"></td>
</tr>
<tr>
<td width="1px" background="/v/vspfiles/templates/90/images/DBox_Border_Left.gif"><img src="/v/vspfiles/templates/90/images/clear1x1.gif" width="1" height="1"></td>
<td width="100%" valign="top">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tbody><tr>
<td><b><img src="/v/vspfiles/templates/90/images/star5.gif"><br>
Great Product</b> </td>
<td align="right"><i>April 28, 2011</i></td>
</tr>
<tr>
<td><i><span class="PageText_L510n">Reviewer</span>:
<span class="PageText_L512n">Anonymous Person</span>
</i><br><br></td>
<td align="right"> </td>
</tr>
</tbody></table>
I used this product and it was great<br>
<br>
<span class="PageText_L514n"><span id="helpful"></span></span> <a href="/reviewhelpful.asp?ProductCode=TRU%2DGDM49&ID=12&yes=yes"><img src="/v/vspfiles/templates/90/images/buttons/btn_reviews_yes.gif" align="absmiddle" border="0"></a>
<a href="/reviewhelpful.asp?ProductCode=TRU%2DGDM49&ID=12&yes=no"><img src="/v/vspfiles/templates/90/images/buttons/btn_reviews_no.gif" align="absmiddle" border="0"></a>
</td>
<td width="1px" background="/v/vspfiles/templates/90/images/DBox_Border_Right.gif"><img src="/v/vspfiles/templates/90/images/clear1x1.gif" width="1" height="1"></td>
</tr><tr>
<td width="1px" valign="top"><img src="/v/vspfiles/templates/90/images/DBox_Border_Left_Bottom.gif"></td>
<td width="100%" valign="top" background="/v/vspfiles/templates/90/images/DBox_Border_Bottom.gif"><img src="/v/vspfiles/templates/90/images/clear1x1.gif" width="1" height="1"></td>
<td width="1px" valign="top"><img src="/v/vspfiles/templates/90/images/DBox_Border_Right_Bottom.gif"></td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
I have dynamically created Reviews inside Tables with class 'helpfulreviews'. I want to take these Tables and essentially hide all but one of them and automatically slide into the next table after a certain period of time using jQuery
Here are Three Reviews, I want one to display and slide into the other after around 10 seconds, then slide into the third review, then rotate back to beginning. I have simplified the example:
<table width="100%" border="1" cellspacing="0" cellpadding="0" class="helpfulreviews">
<tbody>
<tr>
<td>MY FIRST REVIEW GOES HERE<br>Terrible Product</td>
</tr>
</tbody>
</table>
<table width="100%" border="1" cellspacing="0" cellpadding="0" class="helpfulreviews">
<tbody>
<tr>
<td>MY SECOND REVIEW GOES HERE<br>Great Product you have here</td>
</tr>
</tbody>
</table>
<table width="100%" border="1" cellspacing="0" cellpadding="0" class="helpfulreviews">
<tbody>
<tr>
<td>MY THIRD REVIEW GOES HERE<br>This is an awesome product</td>
</tr>
</tbody>
</table>
Full code of one of the tables:
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="helpfulreviews">
<tbody><tr>
<td width="1%"> </td>
<td width="99%">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="colors_descriptionbox">
<tbody><tr>
<td width="1px" valign="top"><img src="/v/vspfiles/templates/90/images/RBox_Border_Left_Top.gif"></td>
<td width="100%" valign="top" background="/v/vspfiles/templates/90/images/DBox_Border_Top.gif"><img src="/v/vspfiles/templates/90/images/clear1x1.gif" width="1" height="1"></td>
<td width="1px" valign="top"><img src="/v/vspfiles/templates/90/images/DBox_Border_Right_Top.gif"></td>
</tr>
<tr>
<td width="1px" background="/v/vspfiles/templates/90/images/DBox_Border_Left.gif"><img src="/v/vspfiles/templates/90/images/clear1x1.gif" width="1" height="1"></td>
<td width="100%" valign="top">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tbody><tr>
<td><b><img src="/v/vspfiles/templates/90/images/star5.gif"><br>
Great Product</b> </td>
<td align="right"><i>April 28, 2011</i></td>
</tr>
<tr>
<td><i><span class="PageText_L510n">Reviewer</span>:
<span class="PageText_L512n">Anonymous Person</span>
</i><br><br></td>
<td align="right"> </td>
</tr>
</tbody></table>
I used this product and it was great<br>
<br>
<span class="PageText_L514n"><span id="helpful"></span></span> <a href="/reviewhelpful.asp?ProductCode=TRU%2DGDM49&ID=12&yes=yes"><img src="/v/vspfiles/templates/90/images/buttons/btn_reviews_yes.gif" align="absmiddle" border="0"></a>
<a href="/reviewhelpful.asp?ProductCode=TRU%2DGDM49&ID=12&yes=no"><img src="/v/vspfiles/templates/90/images/buttons/btn_reviews_no.gif" align="absmiddle" border="0"></a>
</td>
<td width="1px" background="/v/vspfiles/templates/90/images/DBox_Border_Right.gif"><img src="/v/vspfiles/templates/90/images/clear1x1.gif" width="1" height="1"></td>
</tr><tr>
<td width="1px" valign="top"><img src="/v/vspfiles/templates/90/images/DBox_Border_Left_Bottom.gif"></td>
<td width="100%" valign="top" background="/v/vspfiles/templates/90/images/DBox_Border_Bottom.gif"><img src="/v/vspfiles/templates/90/images/clear1x1.gif" width="1" height="1"></td>
<td width="1px" valign="top"><img src="/v/vspfiles/templates/90/images/DBox_Border_Right_Bottom.gif"></td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉耽搁了。这是一个工作示例。显然,您可以调整尺寸和内容来满足您的目的。这个想法是用
overflow:hidden
将表格包装在容器 div 中,并根据需要偏移它们(即,第一个表格定位为填充 div,第二个表格具有margin-left< /code> 等于容器的宽度,第三个左边距是宽度的两倍,等等)
编辑:我更改了代码以基于定义一些变量来动态更改表和值以及内容;这样,您就不必在每次更改评论的大小时都经历并更改一堆值。
Sorry for the delay. Here's a working example. Obviously you can tweak the sizes and stuff to fit your purpose. The idea is to wrap the tables in a container div with
overflow:hidden
and offset them as needed (i.e, the first table is positioned to fill the div, the second hasmargin-left
equal to the width of the container, the third's margin left is twice the width, etc.)EDIT: I changed the code to dynamically change the tables and values and stuff based on defining a few variables; that way you don't have to go through and change a bunch of values everytime you change the size of your reviews.