2013-11-28 34 views
0

如何從colorbox獲得響應(例如提交按鈕)?jQuery colorbox HTML以外的內聯調用

的index.html

$(document).ready(function(){ 

    $(".myclass").colorbox({width:"75%", height:"75%"}); 

    $('#btn').click(function(){ 
     $("#test").val("it works!"); 
    }); 
}); 

<body> 
    <a class='myclass' href="1.html">Click to show the Colorbox</a> 
</body> 

1.HTML

<input type="text" id="test"> 
<input type="submit" id="btn"> 

當我點擊提交按鈕,沒有任何反應。如何調用colorbox的內容並更改內容?

回答

0

更改您這樣的代碼:

 $(document).ready(function() { 
      $(".myclass").colorbox({ 
       width: "75%", 
       height: "75%", 
       onComplete: function() { 
       $('#btn').click(function() { 
        $("#test").val("it works!"); 
       }); 
       } 
      });   
     }); 
+0

感謝馬修...這偉大工程:) – user3046431