简体   繁体   English

在js中插入html div并从中获取选择器

[英]Insert html div in js and take selector from it

I have some HTML content of dialog with button: 我有一些带有按钮的对话框的HTML内容:

<div id="dialogId" class="someClass" style="someStyle">
    <p>Some Content with buttons</p>
</div>

I need to insert it using JS and take div id as a selector for showing a UI dialog: 我需要使用JS插入它,并使用div id作为显示UI对话框的选择器:

AJS.dialog2("#dialogId").show();
AJS.$("#someButtonId").click(function closeWindow() {
    AJS.dialog2("#dialogId").hide();
});
}

How can I do this? 我怎样才能做到这一点? Thanks. 谢谢。

$('body').append('<div id="dialogId" class="someClass" style="someStyle"><p>Some Content with buttons</p></div>');

$('#somebuttonId').on('click',function(){
$('dialogId').hide();//to close the dialog
//$('dialogId').show();//to show the dialog
})

check this code 检查此代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM