问题描述
朋友,
如何将class ="current"应用于菜单项?
我知道如何以静态形式进行操作.
如何以动态方式将其应用于菜单项.
因此,单击菜单项时,会将class ="current"应用于
下面的代码
Hi Friends,
How do I apply class="current" to menu items?
I know how to do it in static form.
How would it be applied to a menu item in a dynamic fashion.
so that the menu item, when clicked, gets class="current" applied to the
below code
<li id="liFamily" class="current"><a href="">By Family</a></li>
<li id="liIndividual"><a href="#">By Individual</a></li>
<li id="liSeating" ><a href="#">By Seating</a></li>
在这里我静态地应用,我想动态地做到这一点.
Here i apply statically, i want to do that dynamically
推荐答案
<ul><li id="liFamily" runat="server" class="current"><a href="">By Family</a></li></ul>
现在您可以在服务器端访问此文件
如果您想在客户端进行操作
您应该在页面的最后使用javascript函数
您应该知道当前菜单,然后可以添加属性..
发挥globla的作用;并在最后一页的每个页面上调用函数
使用当前菜单.
Now you can access this on Server Side
if you want to do it on client side
you should use javascript function at the last of the page
and you should khow about current menu then you can add attribute..
make function as globla; and call function on each page at the last
with current menu.
function setmnu(mnuid)
{
var mnu=document.getElementById(mnuid);
mnu.className="current";
}
setmnu('liFamily');
好的
ok
这篇关于我如何应用class ="current"菜单项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!