0

我试图了解说唱天才如何启用功能,使用户能够突出显示,然后在突出显示完成后显示弹出框。我将如何使用 jquery 做到这一点?

如果有帮助,我还将在我的项目中使用 twitter 引导程序来处理我的项目中的其他项目,包括用户单击按钮后的弹出框。

编辑:第一个示例有效(用户在输入框中选择文本),但第二个示例(用户在“内容”中选择文本)不起作用。

    <p class = 'content'>
    Click and drag the mouse to select text in the inputs.
    </p>
    <input type="text" value="Some text" />
    <input type="text" value="to test on" />

    <div></div>


    <script>
      $(":input").select( function () {
      $("div").text("Something was selected").show().fadeOut(500);
      });

      $("content").select( function () {
      $("div").text("Something else outside of input was selected").show().fadeOut(5000);
      });
    </script>
4

1 回答 1

2

使用JavaScript

document.getElementById("myDiv").onmousedown = function(){
             //Client has pressed the mouse button without releasing it...
             this.onmouseup = function(){
                    document.getElementById("myPopUp").style.display="block";
             };
};

演示

使用jQuery

$("#myDiv").mousedown(function(){

          $("#myDiv").mouseup(function(){

                     $("#myPopUp").show();
          });
});

演示

jQuery 的 .select()

当用户在其中进行文本选择时,选择事件会发送到元素。此事件仅限于input type="text"字段和textarea框。

于 2013-03-12T23:03:04.417 回答