<li><a class="<?php if($_GET['q']=='addons.html');echo 'current';?>" href="addons.html">test</a></li>
<li><a class="<?php if($_GET['q']=='technicalsupport.html');echo 'current';?>" href="technicalsupport.html">example</a></li>
<li><a class="<?php if($_GET['q']=='center.html');echo 'current';?>" href="center.html">center</a></li>
<li><a class="<?php if($_GET['q']=='about.html');echo 'current';?>" href="about.html">about</a></li>
Run Code Online (Sandbox Code Playgroud)
为什么那些都加上当前页面的"当前"?我想class="current"只添加到当前页面
<ul id="test">
<li>test</li>
<li>test</li>
<li>test</li> // add a class to this li
<li>test</li>
<li>test</li>
<li>test</li> // add a class to this li
<li>test</li>
<li>test</li>
<li>test</li> // add a class to this li
</ul>
Run Code Online (Sandbox Code Playgroud)
如何使用jquery向上面的li行添加一个类,我添加了一个注释.谢谢.
$(document).ready(function(){
setTimeout(function() {
window.location.href = $(".user a")[0].href;
}, 2000);
});
Run Code Online (Sandbox Code Playgroud)
我把上面的jquery代码放在一个js file.which由网站的标题模板调用.但在某些页面(没有.user a)显示错误" 0.href is null or not an object在IE状态栏上.如何防止错误显示.