2014-01-14 45 views
0

我正在使用下面的代碼。它工作正常使用jquery將文本複製到客戶端剪貼板

$.each(data, function (index, d) { 
     var clippy_swf = "swf/clippy.swf"; 
     $('#change_this').html('').clippy({ 'text': d.address_1, clippy_path: clippy_swf }); 
    }); 

但我想要這樣,它不在這裏工作。

$.each(data, function (index, d) { 
     if (index != 0) { 
      multiaddr += "<div><span >" + d.address_1 + "</span><span id='change_this_" + index + "'></span></div>"; 
      var clippy_swf = "swf/clippy.swf"; 
      $("#change_this_" + index + "").html('').clippy({ 'text': d.address_1, clippy_path: clippy_swf }); 
     } 
    }); 
+0

如何在動態創建的跨度大眼夾事件綁定工作嗎? –

回答

1

試試這個:

$('.someclass').append(multiaddr); 
    $(document).find("#change_this_" + index + ").html('').clippy({ 'text': d.address_1, clippy_path: clippy_swf }); 

相反的:

$("#change_this_" + index + "").html('').clippy({ 'text': d.address_1, clippy_path: clippy_swf }); 

你有太多的"index,並試圖找到裏面的文件的新的div,但你需要之前添加它

+0

yuuuhooooo。現在,它的工作..謝謝男人.. –

+0

完美提醒接受答案,當你可以幫助其他人與你的同樣的問題:) @RohitKhurana –