【发布时间】:2014-07-04 15:01:15
【问题描述】:
我有一个侧边栏来过滤带有一些参数的人,比如城市和性别。我需要面包屑,这样当我点击性别或城市时,它会破坏新的面包屑,但它还必须保存以前的参数。像这样:
Home / sex / male / city / NY
但我有一个执行此操作的 jquery 代码:
Home / Sex /male (and when i click on city it does this:)
Home / City / NY (it erase the other)
我把代码留在这里:
$('.items label').on('click', function() {
var $this = $(this),
$bc = $('<div class="item"></div>');
$this.parents('li').each(function(n, li) {
var $a = $(li).children('label').clone();
($a.addClass("btn btn-default")).removeAttr("style margin-left");
$bc.prepend($a);
});
$('.btn-breadcrumb').html( $bc.prepend('<a href="#Home" class="btn btn-default"><i class="glyphicon glyphicon-home"></i></a>') );
return false;
})
http://jsfiddle.net/mPsez/3/ 这是我从这个页面得到的一个例子。这段代码的问题和我一样;当您单击 test1、test2 或 test3 时,它会删除前一个。
【问题讨论】:
-
看起来它对我来说工作正常。
标签: jquery html css twitter-bootstrap breadcrumbs