javascript - 更新 jQuery UI 工具提示上的数字

标签 javascript jquery html css tooltip

我有带有工具提示的文件夹,例如“0 个条目”或“5 个条目”等。每次将某些内容放入文件夹时,我都需要将此工具提示编号更新 1。标题并不总是从零开始,我需要更新 $(this) drop div,因为我有很多。这是工作 fiddle http://jsfiddle.net/4ehSG/3

jQuery

$(document).tooltip();

var dropped =0;

$( ".draggable" ).draggable();
    $( ".droppable" ).droppable({
      drop: function( event, ui ) {
        dropped++;
          $( this )
          .attr('title',dropped+' entries')
          .addClass( "ui-state-highlight" )
          .find( "p" )
            .html( "Dropped!" );
          $( ".draggable" ).fadeOut();
      }
    });

HTML

<div class="draggable ui-widget-content">
  <p>Drag me to my target</p>
</div>

<div class="droppable ui-widget-header" title='2 entries'>
  <p>Drop here</p>
</div>

最佳答案

这是您可以执行的操作的示例:http://jsfiddle.net/4ehSG/9/

  drop: function( event, ui ) {
      var dropped = parseInt($(this).attr('title')) + 1;
      $( this )
      .attr('title',dropped+' entries')
      .addClass( "ui-state-highlight" )
      .find( "p" )
        .html( "Dropped!" );
      $( ".draggable" ).fadeOut();
  }

关于javascript - 更新 jQuery UI 工具提示上的数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18855473/

相关文章:

javascript - 使用 TypeScript 2.0 导入 js 文件

jquery - 在 jQuery AJAX 帖子中,是否有可能不发送数据有效负载?

javascript - 单击查询选择器选择的所有链接

javascript - 如何在避免闪烁的同时平移元素?

html - 选择子菜单项时遇到问题

javascript - 如何在更新JavaScript中的一个元素时更改所有数组?

javascript - 使用jquery过滤隐藏表行

javascript - 下拉选择的值没有在视觉上更新(html-select,javascript)

Javascript 有条件地构建 mvc actionlink

javascript - 中心导航栏和 slider