请参阅这里:(多亏了我可以让Kittenz了解这一点)
码
//Initially the need size should be shown
var need_size=true;
//when the cursor enters the button area
$('#cart-btn').mouseenter(function(){
//we check if the message needs to be shown
if(need_size==true){
//if yes, show it
$(this).find('span').html('NEED SIZE');
}
});
$('#cart-btn').mouseleave(function(){
//when the cursor leaves the button, we restore back the text
$(this).find('span').html('ADD TO CART');
});
$(".dropdown-menu li label").click(function(){
var selected = $(this).text();
$(this).parents('#cart-dd').find('.dropdown-toggle').html(selected);
//we disable the need size text to be shown once an option is selected
need_size=false;
});当跨度“需要大小”消息显示时,如果用户要单击按钮,我将如何打开下拉列表。下面是我所指的不正确的代码示例:
if(need_size==true){
//if yes, show it
$(this).find('span').html('NEED SIZE').click('span').find('.dropdown-toggle').addClass('open');
}发布于 2014-05-28 17:59:11
从引导文档开始
$().dropdown('toggle')切换给定导航条或选项卡导航的下拉菜单。
因此,用于显示/隐藏下拉列表,例如在声明的mouseenter事件期间。
if(need_size==true){
$(".cart-dd.dropdown-toggle").dropdown("toggle");
}https://stackoverflow.com/questions/23918079
复制相似问题