thanks in advance to all. I really don't know where to start my question's and whats the right terms for what I'm looking for, but sure you guys have some answers for a newbie. I'm trying to get better with js and I want to create a simple push notification msg that will show some pre-written text in the html markup. I'v achieved that with some functions manipulating the css but not sure if its a good method of doing so.
// get msg div
var msg = document.getElementById('msg');
// get button
var btn = document.getElementById('btn');
// get test button
var closeBtn = document.getElementById('closeBtn');
// event lisnters - click btn to run msg
btn.addEventListener('click',runMsg);
// event lisnters - click btn to close msg
closeBtn.addEventListener('click',closeMsg);
// functions list
function runMsg(){
msg.style.display = 'block'
}
function closeMsg(e){
if(e.target === closeBtn){
msg.style.display = 'none';
}
}
1.method one: what is a better way of doing that? creating the html markup and all the css premade and in position just hidden and using js to reveal it?
2.method two: creating all of the html markup using js when a user clicks a certain element using the createElemnt() method ?
**I'm just curious how all the plugins out there create this, my guess is that they have the markup ready and they just linked the two together in some way.
hoping I was clear, cheers to all.
.show().