首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >引导下拉-从span开始打开

问引导下拉-从span开始打开
EN

Stack Overflow用户
提问于 2014-05-28 17:21:51
回答 1查看 407关注 0票数 0

请参阅这里:(多亏了我可以让Kittenz了解这一点)

码

代码语言:javascript
复制
//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;
});

当跨度“需要大小”消息显示时,如果用户要单击按钮,我将如何打开下拉列表。下面是我所指的不正确的代码示例:

代码语言:javascript
复制
 if(need_size==true){
    //if yes, show it
    $(this).find('span').html('NEED SIZE').click('span').find('.dropdown-toggle').addClass('open');
  }
EN

回答 1

Stack Overflow用户

发布于 2014-05-28 17:59:11

从引导文档开始

代码语言:javascript
复制
$().dropdown('toggle')

切换给定导航条或选项卡导航的下拉菜单。

因此,用于显示/隐藏下拉列表,例如在声明的mouseenter事件期间。

代码语言:javascript
复制
if(need_size==true){
    $(".cart-dd.dropdown-toggle").dropdown("toggle");
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23918079

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档