When you click the switch, the audience clickListener()
is called. Once it’s called, clickListener transforms the CSS residential properties of the switch’s youngsters (“. title” and also “. loader”).
This has absolutely nothing to do with JavaScript. This is a CSS trouble.
When you alter the display screen sort of “. loader”, CSS is the placement moving to the left since the switch overruns from it’s moms and dad container, when inline
resembles block
You can accomplish the very same impact to the switch by means of making use of inline-block
rather, or simply establishing the textContent
to “” (absolutely nothing).
You likewise had a key in your code, you finished << period>>
with a <
rather.
Right here is an instance of making use of inline-block
as opposed to inline
:.
feature clickListener() {
loader.style.display='inline-block';.
title.style.display='none';.
}
switch {
elevation: 3rem;.
extra padding: 0 1rem;.
margin-right: 20px;.
}
#loader {
display screen: none;.
}
<< div course=" switches">
<> < switch>> 1<.
<< switch>> 2<.
<< switch onclick=" clickListener()">
<> < period id=" title">> Press< < period id=" loader"><> .
<