0

我正在使用它来将文本复制到剪贴板..

http://www.steamdev.com/zclip/

我试过这样,但我无法将复制的文本放入剪贴板..

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>

<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="js/jquery.zclip.js"></script>

<script>

    $(document).ready(function(){


        $('textarea#showthis').zclip({
            path:'js/ZeroClipboard.swf',
            copy:function(){return $('#showthis').val();}
        });


    });

    function myfunc2()
    {
         var selectedobj=document.getElementById('showthis');

        if(selectedobj.className=='hide')
        {  //check if classname is hide 
            selectedobj.style.display = "block";
            selectedobj.readOnly=true;
            selectedobj.className ='show';
         } else {
            selectedobj.style.display = "none";
            selectedobj.className ='hide';
         }
    }
</script>
 </head>

 <body>
   <label onclick="myfunc2()">Click here</label>
   <textarea id="showthis" style="display:none" class="hide"  readonly>hi, how are you?</textarea>
 </body>
</html>

请告诉我出了什么问题!(我不知道 javascript 和 jquery 的东西!)

4

1 回答 1

1
 function myfunc2() {
   if($('#showthis').css('display') == 'none'){
    $('#showthis').show().removeClass('hide').addClass('show');
  }else{
    $('#showthis').hide().removeClass('show').addClass('hide');
  }
 }
于 2012-11-29T14:31:12.210 回答