how to copy url from address bar to clipboard using jquery

This question already has an answer here:

  • How do I copy to the clipboard in JavaScript? 49 answers

  • location.href will give you the URL following code will work for you.

    $(document).ready(function(){
       $('#div1').click(function(){
           $("#url1").html(location.href);   
        });
    });
    

    click here for demo DEMO

    check my new code i have done it using zclip

    DEMO 2


    Get the URL.

    var pathname = window.location.pathname;
    

    And follow these instructions to copy:

    http://ready2gosoft.com/jquery-javascript/copy-clipboard-javascript.html

    链接地址: http://www.djcxy.com/p/19734.html

    上一篇: 通过JavaScript进行剪贴板操作

    下一篇: 如何使用jquery将地址栏中的url复制到剪贴板