几乎解决了这个问题,但似乎我不允许与jQuery“a []”标记内的变量匹配。我试图用的显示活动/非活动状态,当用户点击地图上的相应区域的链接列表连接的交互式地图 -找到并添加/删除链接与匹配的rel值
// Inside a click event with var active containing the fetch from the map
var active = "Lorem ipsum";
if($('a[rel^=' + active + ']', '.regions')) {
if ($('a[rel^=' + active + ']', '.regions').hasClass('active')) {
$('a[rel^=' + active + ']', '.regions').removeClass('active');
}
else {
$('a[rel^=' + active + ']', '.regions').addClass('active');
}
}
对不起,我误解你的代码,你也解决了它。谢谢! – 2012-01-02 01:38:57