I'm trying to make a page where you can create "documents" that are divs with specific properties.
For now I thought about name & color.
First, when you click in the body, you can create a document that is called "something+i" (i is its ID) then, when you click a specific document you can access a menu to edit its color and its name.
finally when you close the menu by clicking OK the specific document is updated.
Do you have any idea on how to do that? Thanks a lot for the help.
var i = 1;
$(function(){
$(document.body).click(function(e){
var div = $("<div />", { "class":"document", id:"document"+i })
.css({
"left": e.pageX + 'px',
"top": e.pageY + 'px'
})
.append($( "<p>document</p>")+i )
.appendTo(document.body);
$('.document').click(function(event){
event.stopPropagation();
});
$('.menu').click(function(event){
event.stopPropagation();
});
document.querySelector(".document").addEventListener("click", function(){
document.querySelector(".menu").style.display = "block";
});
document.querySelector(".validate").addEventListener("click", function(){
document.querySelector(".menu").style.display = "none";
});
i++;
});
});
body{
width: 100vw;
height: 100vh;
background: grey;
}
.document {
position: absolute;
transform: translate(-50%, -50%);
opacity: 1;
background-color: red;
resize:both;
overflow: auto;
filter: drop-shadow(0 0 0.2rem black);
}
.menu{display: none;}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<body>
<div class="menu">
<li><input type="text" id="name" name="name" size="10" placeholder="name"></li>
<li><input type="text" id="color" name="color" size="10" placeholder="color"></li>
<button class ="validate">OK</button>
</div>
</body>