已选择菜单项
我在 ASP.NET 母版页中创建了一个菜单。我已经为菜单项(如悬停和链接)实现了 CSS 属性,但我无法实现用于更改菜单中所选项目颜色的属性。
我是否需要编写任何 JavaScript 或 jQuery 代码来识别菜单中的所选项目?请帮助我,因为我对这种类型的菜单项很陌生。
I have a menu created in ASP.NET master page. I have implemented CSS properties to menu items like hover and link, but I am not able to implement the properties for changing the color of the selected item in the menu.
Do I need to write any JavaScript or jQuery code for identifying the selected item in the menu? Please help me, as I am new to this type of menu items.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的意思是要永久更改菜单项的颜色(例如,导航菜单的当前页面选项卡始终是某种特定的颜色),您可以在 ASP 中通过向单击时的菜单项。我不是 ASP 类型的人,但在 PHP 中,您可以通过执行以下操作来做到这一点:
然后当加载有问题的页面时,导航代码应该显示如下内容:
if $_GET[page]=n then将 " class=\"selected\"" 回显到锚标记中。
知道我的意思吗?我没有输入上面 if 语句的代码,因为我很确定 ASP 与 PHP 有点不同,无论如何您都必须翻译,但我希望这会有所帮助。
Andy
编辑:## 这是我在短暂接触 google 后对 ASP 的猜测:##
if you mean that you want to change the color of a menu item persistently (like, say, the current page tab of a navigation menu is always some particular color), you can do this in ASP by adding a class or id attribute to the menu item when it is clicked. I'm not an ASP kind of guy, but in PHP, you can do it by doing something like:
and then when the page in question is loaded, the navigation code should say something like:
if $_GET[page]=n then echo " class=\"selected\"" into the anchor tag.
know what i mean? I didn't type out the code for the above if statement because I'm pretty sure ASP is a little different from PHP, and you would have to translate anyway, but I hope this is helpful.
Andy
Edit: ## Here's my ASP guesswork after a brief encounter with google: ##