我正在使用 bootstrap 中的 scrollpsy。
我举了一个例子来说明我正在尝试做的事情:
一切都很好,他在每个部分 id 传递一个活动类li
,但我想在每个部分的标题处更改背景
例如:
如果#studio
background-color: #0915ff;
如果#green
background-color: 085606;
$(function() {
var $spy = $('.nav');
$spy.bind("activate", function(e) {
//e.target is the current <li> element
var header = $(e.target).find("a").attr("href");
alert (header);
$studio = $('#studio')
$duplex = $('#duplex')
$tower = $('#tower')
If( $(header) == "#studio" ) window.alert( “ALERT ACTIVED”);
});
});