-5
Abstracting: I don’t know about Javascript, but I know I can do what I want with Javascript. I would like to know how to check if an input is being clicked, and when it is, I would like to add css classes to other page elements.
How do I do that?
-5
Abstracting: I don’t know about Javascript, but I know I can do what I want with Javascript. I would like to know how to check if an input is being clicked, and when it is, I would like to add css classes to other page elements.
How do I do that?
0
Vc can use a pseudo element in div who has a input inside, as with the focus-within vc show or not the pseudo element that covers the entire site underneath. Nor need JS for this
div:focus-within::after {
content: "";
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background-color: rgba(0,0,0,0.5);
z-index: 1
}
.foca {
position: relative;
z-index: 2;
}
<div class="pesquisa">
<input class="foca" type="text">
</div>
<div>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Unde sequi architecto fugiat, voluptas deleniti debitis harum, rem est voluptates minima facere neque quis ullam asperiores ab necessitatibus nostrum porro velit!
</div>
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.
I found something that can help you: https://www.w3schools.com/jsref/event_onclick.asp
– Maury Developer
Will it be a single field? Or several?
– Risk
I want to click the input and add a background to the site
– Leonardo Henrique
Example:
<input type="number" onclick="myFunction()">– Maury Developer
Your question is not clear in more detail than you want more exactly.
– hugocsl
I specifically want the effect that occurs when clicking on the https://www.shoptime.com.br/ search box where the background darkens
– Leonardo Henrique
Using the direct function call of the html <input onchange="function()"> is not appropriate. The most appropriate is to make javascript wait for event object.onclick = Function(){ its code};
– Risk