【问题标题】:Applying a focus style event to a UL tagit element将焦点样式事件应用于 UL tagit 元素
【发布时间】:2014-06-11 20:38:38
【问题描述】:

使用 jquery Tagit 并希望将 css 焦点应用于 UL 标记。

我想不出办法做到这一点,我对 jquery 的尝试没有成功。

我试过例如:

<ul name="addtags" id="addtags"></ul>

$( "#addtags" ).click(function() {
  $("#addtags").attr('id', 'addtagsfocus');
});

$( "#addtagsfocus" ).bind('clickoutside', function() {
  $("#addtagsfocus").attr('id', 'addtags'); 
});

在点击时有效,但我无法触发模糊/点击外部等功能。

有什么帮助吗?

【问题讨论】:

    标签: javascript jquery css html-lists tag-it


    【解决方案1】:

    给你的 UL 一个 tabindex 属性:

    <ul name="addtags" id="addtags" tabindex="1">
    

    然后它变得可聚焦并且现在应用焦点/模糊事件。

    演示:http://jsfiddle.net/ygalanter/EV4Yc/1/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-12
      • 2020-04-25
      • 2013-04-10
      • 1970-01-01
      • 2012-09-23
      相关资源
      最近更新 更多