Javascript如何为选中的列表项添加复选标记

时间:2016-01-04 16:10:29

标签: javascript jquery html

我有这个HTML代码。每个按钮有两个按钮,其下面有列表项。这是html代码:

<div class="col-xs-8">
    <div class="dropdown pull-left">
      <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
        View
        <span class="caret"></span>
      </button>
      <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
        <li role="presentation">
          <a data-bind="click: function() { format('sgml_as_html') }">
            Show Tags
          </a>
        </li>

        <li role="presentation">
          <a data-bind="click: function() { format('html') };">
           Quick View
          </a>
        </li>

        <li role="presentation">
          <a data-bind="click: function() { format('show_link_targets') };">
            Show Link Targets
          </a>
        </li>

        <li role="presentation">
          <a data-bind="click: function() { format('show_all_link_targets') };">
            Show All Link Targets
          </a>
        </li>

      </ul>
    </div>

    <div class="dropdown pull-left" style="margin-left: 10px;">
      <button class="btn btn-default dropdown-toggle" type="button" id="dropdown_menu_preview" data-toggle="dropdown" aria-expanded="true">
        Preview
        <span class="caret"></span>
      </button>
      <ul class="dropdown-menu" role="menu" aria-labelledby="dropdown_menu_preview">
        <li>
          <a data-bind="click: function() { format('bwd_preview') };">
            BWD Preview
          </a>
        </li>

        <li>
          <a data-bind="click: function() { format('blaw_preview') };">
            BLAW Preview (Coming Soon)
          </a>
        </li>

        <li>

          <a data-bind="click: function() { format('print_preview') };">
            Print Preview (default Notif Format)
          </a>
        </li>


      </ul>
    </div>



    </div>

我想看看如何在java脚本中为添加的列表项添加复选标记。这是html Unicode字符我想使用链接中列出的复选标记:http://www.w3schools.com/charsets/ref_utf_dingbats.asp

1 个答案:

答案 0 :(得分:0)

想通了。你必须做这样的事情。

<span data-bind="visible: format() == 'show_link_targets'"><i class="fa fa-check"></i></span>