通过计时器进行菜单切换 [英] Menu switch through a timer
问题描述
嗨
我有一个问题:
如何使用计时器在aspx中切换MenuItem
我想使用计时器更改MenuItem,例如每隔30秒,下一个MenuItem必须显示
我找不到任何帮助
有人有解决办法吗?
请帮助
Hi
I''ve got a question:
How can I switch the MenuItem in aspx with a timer
i want to change the MenuItem with a timer for example ervery 30sec the next MenuItem have to show
I can''t find any help
Does anybody have a solution?
pls help
推荐答案
基本机制:
A basic mechanism:
- 在页面上包含jquery
- 提供菜单项id(例如menuItem1,menuItem2等).
- 在javascript中声明一个计数器变量并将其设置为1. 使用jQuery隐藏当前菜单项:
- Include jquery on your page
- Give your menu items ids like menuItem1, menuItem2 etc.
- Declare a counter varible in javascript and set it to 1. use jquery to hide the current menu item:
("#menuItem"+counter).hide()
然后将其添加到计数器测试中,以查看menuItem是否存在(请参阅此处 [
("#menuItem"+counter).hide()
then add one to the counter test to see if the menuItem exists (see here[^]). If it doesn''t, you have shown the last item, reset the counter to 1. Now show the net menuitem, code>
(#menuItem" +< i>计数器< ;/i>).show()
现在循环.您可以使用 JavaScript计时事件 [
("#menuItem"+<i>counter</i>).show()
Now loop. You can do this using either Javascript timing event[^] to call the function, or use jquery''s delay
method in the function in step 3, and have it call itself.
这不会很顺利:要改进此功能,请先获取下一个项目,进行显示,然后使用show
mehtod的回调隐藏刚刚完成的项目.请参见 http://api.jquery.com/show/ [
This won''t be very smooth: to improve this get the next item first, show it, and use the show
mehtod''s callback to hide item that has just been finished with. See http://api.jquery.com/show/[^] for help how to do this. If you use the jquery delay you should add the recursive code to the callback.
这篇关于通过计时器进行菜单切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!