[英]Open div when click a another div
I have a html structure. 我有一个html结构。 With the following: 具有以下内容:
<div class="edit"><a class="formtri" href="#">CHANGE</a>
And: 和:
<div id="user_adr" style="display:none">
I want, when i click CHANGE, get user_adr
div on front. 我想要,当我单击CHANGE时,将user_adr
div放在前面。 Ajax or other solution. Ajax或其他解决方案。 I tried jQuery .load
function but it's not work. 我尝试了jQuery .load
函数,但无法正常工作。 How can i do this? 我怎样才能做到这一点?
you can use jquery ui. dialog()
您可以使用jquery ui. dialog()
jquery ui. dialog()
method to show a dialog box. jquery ui. dialog()
方法显示一个对话框。 like this. 像这样。 Jquery dialog jQuery对话框
<script>
$(function() {
$( "#dialog" ).dialog({
autoOpen: false,
show: {
effect: "blind",
duration: 1000
},
hide: {
effect: "explode",
duration: 1000
}
});
$( "#opener" ).click(function() {
$( "#dialog" ).dialog( "open" );
});
});
</script>
</head>
<body>
<div id="dialog" title="Basic dialog">
<p>This is an animated dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<button id="opener">Open Dialog</button>
alternatively you can use toggle functionality. 或者,您可以使用切换功能。
$('.edit').on('click',function(){
$('#user_adr').toggle();
});
if not toggle. 如果没有切换。 then alternative method of toggle is this. 那么切换的替代方法就是这个。
$('.edit').on('click',function(){
if('#user_adr').is('visible'))
{
$('#user_adr').show();
}
else
{
$('#user_adr').hide();
}
});
//to change display to none //将显示更改为无
$('#yourDivId).attr('display','none');
if in case there is any other div with same class name edit above solutions may not be helpful so better u keep a unique id as "change" 如果万一还有其他具有相同类名的div,则上述解决方案可能没有帮助,因此最好将唯一ID保留为“ change”
<div class="edit"><a class="formtri" id="change" href="#">CHANGE</a>
$("#change").on("click", function(){
$('#user_adr').show();
});
$("#change").on("click", function(){
$('#user_adr').toggle();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.