1
Good afternoon, I’m developing a pure javascript modal.
What happens is the following... the script detects that there are tags with the class "modal"<div class="modal">
, and when it finds one or more it inserts the tags with the classes already defined.
What happens... one of the functions inserts a div into that div with the following class<div class="modal loading"></div>
and so it enters as one more item within the javascript loop.
Is there any way to select only the modal that has no other class inside?
I’m using this call in my javascript
var modal = document.getElementsByClassName('modal');
modal[i].innerHTML = "<div class='modal loading'></div>"
My CSS is that way.
.modal>.loading {
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 10%;
background: url(loader.gif) center no-repeat;
}
The answer is almost perfect, just a question, there is some way in querySelectorAll to select exactly that one class instead of passing the :not parameter()?
– 김무진
@김무진 Selecting only . modal?
– Sam
Sorry I was implementing the code adapting the thing forgot to inhibit the previous, it solved my problem
– 김무진