如何更改导航栏中选定项目的类属性 [英] how to change the class attribute of a selected item in the navigation bar
问题描述
< div class =nav 我使用的是twitter bootstrap和grails, -collapse>
< ul class =nav>
< li>< a href =$ {createLink(uri:'/ request / new')}>我的链接< / a>< / li>
< / ul>
< / div>
在我的页面上,我有以下内容:
< HTML>
< head>
< meta name =layoutcontent =bootstrap>
< / head>
< body>
sometext
< / body>
< / html>
问题 在我的布局中,如何检测何时点击 首先,在你的布局中,你可以做这样的事情: 并在您的页面中: I'm using twitter bootstrap with grails and have the following in my layout: On my page I have the following: Question In my layout how do I detect when the Here is how I tend to do this. First, in your layout, you would do something like this: And in your page: 这篇关于如何更改导航栏中选定项目的类属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
My Link
动作?所以我可以使用 class =active
pre> < div class =nav-collapse>
< ul class =nav>
< li class =$ {pageProperty(name:'meta.nav')。equals('foo')?'active':null}>< a href =$ {createLink(uri :'/ request / new')}>我的链接< / a>< / li>
< / ul>
< / div>
< HTML>
< head>
< meta name =layoutcontent =bootstrap>
< meta name =navcontent =foo/>
< / head>
< body>
sometext
< / body>
< / html>
foo
是应用 .active
class。 <div class="nav-collapse">
<ul class="nav">
<li><a href="${createLink(uri: '/request/new')}">My Link</a></li>
</ul>
</div>
<html>
<head>
<meta name="layout" content="bootstrap">
</head>
<body>
sometext
</body>
</html>
My Link
action is clicked? so that I can highlight it using class="active"
<div class="nav-collapse">
<ul class="nav">
<li class="${ pageProperty(name:'meta.nav').equals( 'foo' ) ? 'active' : null }"><a href="${createLink(uri: '/request/new')}">My Link</a></li>
</ul>
</div>
<html>
<head>
<meta name="layout" content="bootstrap">
<meta name="nav" content="foo"/>
</head>
<body>
sometext
</body>
</html>
foo
is the trigger to apply the .active
class.