【问题标题】:Dropdown selected icon to be change下拉选中要更改的图标
【发布时间】:2014-02-28 09:23:56
【问题描述】:

我已经在其中实施了社交网站。朋友的状态应该根据选择的下拉按钮而改变。我已经添加了我的代码。请提出合适的答案

<div class="dropdown" id="dLabel">
  <button class="btn-small btn-default " data-hover="dropdown" data-target="#" href="#">

朋友

         <li><a tabindex="-1" href="#">Close Friends</a></li>
         <li><a tabindex="-1" href="#">Notification</a></li>
         <li><a tabindex="-1" href="#">Acquaintances</a></li>
         <li class="divider"></li>
         <li><a tabindex="-1" href="#">Add Another List</a></li>
         <li><a tabindex="-1" href="#">Suggest Friends</a></li>
         <li class="divider"></li>
         <li><a tabindex="-1" href="#">Report/Block</a></li>
         <li><a tabindex="-1" href="#">Unfriend</a></li>

我的字形图标要更改。即我的下拉列表包含上面。通常图标会显示 glyphicon-ok 图标。如果我选择密友,图标将变为 glyphicon-star。如果我选择熟人,另一个图标想要改变。喜欢 facebook 的朋友状态。当我们改变亲密的朋友时。图标更改为黄色星。同样,我想改变,请给我合适的答案

【问题讨论】:

  • 不明白你的问题是什么
  • 请明确你想要什么。也许只是用简单的英语一步一步地列出你想要的东西。

标签: javascript twitter-bootstrap yii


【解决方案1】:

首先,我理解了你的问题,但不知道你想如何达到你的要求。但是无论您使用什么,它都会非常有用。 我建议你使用这样的东西

<select  id="dLabel">
<option value="CloseFriends">Close Friends</option>
<option value="Notification">Notification</option>
//....other options as you used in your code

</select>

向该下拉列表添加一个侦听器,并根据 if 条件进行相应的编码。

$('#dLabel').bind('change', function(e,p) {  // bind event listener on that component
var dat=$(this).val(); //get the value of the selected option

if(val=='CloseFriends'){
    //action
     }
   //similarly your other conditions

        });

【讨论】:

    猜你喜欢
    • 2019-07-19
    • 2018-10-04
    • 1970-01-01
    • 2017-08-31
    • 2020-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-20
    相关资源
    最近更新 更多