2016-12-04 35 views
0

嘿家伙,所以我需要打开一个表的弹出正在举行一个div当图像或超链接被点击我的继承人代码JQUERY或Java脚本弹出负荷从格表的onclick

<html> 
<body> 
<div id="tabla"> </h1> </div> 
<a href="#" id="openDialog">Click me</a> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
<script> 
$(function() { 
    $("#openDialog").on("click", function(){ 
     $("#tabla").dialog({ 
      height: 140, 
      modal: true 
     }); 
     $("#tabla").show(); 
    }); 
}); 

</script> 

那里有一个功能该DIV ID保持表,因此功能必须由ID为填充表感谢弹出来电GUYS

回答

0

也许你需要的东西是这样的:

HTML

<button id="trigger"> 
    open dialog 
</button> 

<div class="modal"> 
    <div class="modal__body"> 
    <table> 
     <tr> 
     <td> 
      Test 
     </td> 
     <td> 
      Test 
     </td> 
     <td> 
      Test 
     </td> 
     </tr> 
     <tr> 
     <td> 
      Test 
     </td> 
     <td> 
      Test 
     </td> 
     <td> 
      Test 
     </td> 
     </tr> 
    </table> 
    </div> 
</div> 

CSS

.modal { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.7); 
} 

.modal__body { 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%); 
    width: 600px; 
    height: 400px; 
    background: white; 
} 

.show { 
    display: block; 
} 

jQuery的

$('#trigger').click(function() { 
    $('.modal').addClass('show'); 
}); 

$('.modal').click(function() { 
    $(this).removeClass('show'); 
}); 

只需添加您的表modal__body

0

您可以使用jQuery UI对话来实现你正在尝试做的。如果你给你的div包含您的表dialog类:

<div id="dialog" title="Basic dialog"> 
    <table></table 
</div> 

然后,你需要挂接到任何你想要触发弹出你的a标签或单击事件:

$("#openDialog").click(function() { 
    $("#dialog").dialog(); 
}); 

不要担心关闭,因为它在该对话框上有一个关闭按钮。更多信息here