i want like this 为什么课程提醒警报 - 成功无法添加标签href?
<ul class="nav nav-pills" id="nav">
@foreach($menu as $d)
<li role="presentation"><a class="text-capitalize " href="{!! $d->name !!}">{!! $d->name !!}</a></li>
@endforeach
</ul>
<script type="text/javascript">
$(document).ready(function() {
// get current URL path and assign 'active' class
var pathname = window.location.pathname;
$('.nav > li > a[href="'+pathname+'"]').parent().addClass('alert alert-success');
})
</script>
答案 0 :(得分:0)
尝试使用以下
$('.nav > li > a[href*="'+pathname+'"]').parent().addClass('alert alert-success');