通过计时器进行菜单切换 [英] Menu switch through a timer

查看:95
本文介绍了通过计时器进行菜单切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个问题:

如何使用计时器在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:

  1. 在页面上包含jquery
  2. 提供菜单项id(例如menuItem1,menuItem2等).
  3. 在javascript中声明一个计数器变量并将其设置为1.
  4. 使用jQuery隐藏当前菜单项:

  1. Include jquery on your page
  2. Give your menu items ids like menuItem1, menuItem2 etc.
  3. Declare a counter varible in javascript and set it to 1.
  4. 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>).s​​how()
  • 现在循环.您可以使用 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屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆