简单的基于文本的菜单 - 按钮之间的toggeling(DHTML,javascript) [英] simple text based menu - toggeling between buttons (DHTML, javascript)

查看:71
本文介绍了简单的基于文本的菜单 - 按钮之间的toggeling(DHTML,javascript)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道在按钮之间切换的简单方法。


我使用过的函数:

Does anybody know a simple way to toggle between buttons.

The functions I have used:

展开 | 选择 | Wrap | 行号

推荐答案

你只需要标准方法document.getElementById(),除非你想支持IE4和Netscape 4,两个超过10的老式漏洞浏览器岁。所有现代浏览器都支持document.getElementById()。

切换按钮的一种简单方法是使用一个函数将按钮名称/ id作为参数并隐藏其余部分或更改它们的除了要显示/设置的类之外的类。


使用document.getElementsByTagName(tagName)获取所有标记(其中tagName是标记的名称)。按钮是否输入(type = button)标签?那文本怎么样?
You only need document.getElementById(), the standard method, unless you want to support IE4 and Netscape 4, two old buggy browsers that are over 10 years old. All modern browsers support document.getElementById().

An easier way to toggle buttons is to have one function which takes the button name/id as an argument and hides the rest or changes their class except the one to be shown/set.

Use document.getElementsByTagName(tagName) to get all the tags (where tagName is the name of the tag). Are the buttons input (type=button) tags? What about the text?


感谢您回复我。

Thanks for getting back to me.


您只需要document.getElementById( ),标准方法,除非你想支持IE4和Netscape 4,两个超过10年的旧bug浏览器。所有现代浏览器都支持document.getElementById()。
You only need document.getElementById(), the standard method, unless you want to support IE4 and Netscape 4, two old buggy browsers that are over 10 years old. All modern browsers support document.getElementById().



啊,是的。好点子。猜猜我在尝试自学时应该读一本新书。 ; -\

Ah, yes. Good point. Guess I should have read a newer book when trying to teach myself. ;-\


切换按钮的一种简单方法是使用一个函数将按钮名称/ id作为参数并隐藏其余部分或更改他们的类,除了要显示/设置的类。


使用document.getElementsByTagName(tagName)获取所有标记(其中tagName是标记的名称)。按钮是否输入(type = button)标签?那文字怎么样?
An easier way to toggle buttons is to have one function which takes the button name/id as an argument and hides the rest or changes their class except the one to be shown/set.

Use document.getElementsByTagName(tagName) to get all the tags (where tagName is the name of the tag). Are the buttons input (type=button) tags? What about the text.



按钮只是文本链接。我不想改变所有< a>的类。该文档中的标签仅包含某些ID。也许构建一个包含我想要设置为不同类的ID的数组将是一个开始。使用变量标记单击的按钮,然后让该数组运行为所有按钮层设置新类,但标记的按钮层。


说实话,我还没有解决过。部分问题是想出Javascript。我之前没有使用它。

The buttons are just text links. I don''t want to change the class of all the <a> tags in that document only of certain IDs. Perhaps building an array with the IDs that I would want to set to a different class would be a start. Flagging the clicked button with a variable and then letting that array run setting a new class for all the button layers but the flagged one.

To be honest I haven''t worked it out yet. Part of the problem is to figure Javascript out. I have not used it before.



这些按钮只是文本链接。我不想改变所有< a>的类。该文档中的标签仅包含某些ID。也许构建一个包含我想要设置为不同类的ID的数组将是一个开始。使用变量标记单击的按钮,然后让该数组运行为所有按钮层设置新类,但标记的按钮层。
The buttons are just text links. I don''t want to change the class of all the <a> tags in that document only of certain IDs. Perhaps building an array with the IDs that I would want to set to a different class would be a start. Flagging the clicked button with a variable and then letting that array run setting a new class for all the button layers but the flagged one.



这是一种可能性,或者使用elem.getElementsByTagName(tagName),其中elem是包含仅需要的链接而没有其他链接的父元素,例如表格行。

That''s a possibility or by using elem.getElementsByTagName(tagName) where elem is the parent element containing the links required only and no other links, e.g. the table row.


这篇关于简单的基于文本的菜单 - 按钮之间的toggeling(DHTML,javascript)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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