Posts by Lucas de Carvalho • 6,427 points
260 posts
-
1
votes1
answer40
viewsQ: Pass parameters to a function being passed from parameter to parameter
Imagine this, I have the function 1 that needs to receive as a parameter a function callback. Function 2 needs to receive a parameter and I need to pass it as a function value1, as I would pass this…
-
1
votes2
answers23
viewsA: onSearch event (html and Java)
What’s missing is that you didn’t get the input value, so you never got inside the IF and you thought it wasn’t working, see with a log console inside: <!DOCTYPE html> <html…
javascriptanswered Lucas de Carvalho 6,427 -
0
votes1
answer117
viewsQ: BEM pattern in CSS
I am using the standard WELL and came to me a doubt, when I have an element with children and grandchildren, how should I name my classes? I will use code to give this example: <header…
-
1
votes2
answers897
viewsA: How do I use the properties of a parent element in the child’s CSS?
You can use 2 selectors, the > and the * and do so: .pai > * { color: blue; } <div class="pai"> <span>Eu não estu dentro da li</span> <ul> <li>Eu estou dentro da…
-
1
votes0
answers49
viewsQ: How does jQuery’s "on" work?
I’m doing some tests, and, I have some custom events on the platform I use, however, the window.addeventlistener does not work according to the on() of jQuery. the event I use, let’s assume that the…
-
0
votes1
answer35
viewsQ: Pick up classes with - (hyphen)
Good morning. Today I came across a problem I’m not sure how to solve. A promotion system generates some classes for some elements on my page, the problem is the way it generates, it puts…
cssasked Lucas de Carvalho 6,427 -
2
votes4
answers171
viewsA: How to find a vector using a JAVASCRIPT function
You are giving false because the index does not return a boolean, and also will not return the value 'Reactjs', so, result will never be equal to 'Reactjs'. The index() method returns the first…
javascriptanswered Lucas de Carvalho 6,427 -
6
votes2
answers3244
viewsQ: Multipart Formdata is a data structure?
How it works "behind the scenes". I know that when we send a request and the body we define as JSON, this is a data structure that will be sent in JSON form, in which case Multipart Formdata is also…
asked Lucas de Carvalho 6,427 -
2
votes1
answer52
viewsQ: Curious situation when entering grid-area with Javascript
I am inserting some stylizations in a little project that I am doing, and I have a foreach running in the DOM to go through a list, it turns out that if I add a grid-area and put the Dice as grid…
-
0
votes1
answer329
viewsQ: Remove comma from map
Good afternoon. I’m trying to create some elements dynamically coming from an API, only I’m running the map for this, the problem is that along with it, commas appear in the middle of the li’s that…
-
1
votes1
answer165
viewsQ: How exactly does the grid area work?
I’m trying to style the page using grid in CSS but I don’t think I understand very well how the area template works. What are you doing: .pai { display: grid; grid-template-columns: repeat(3, 50px)…
-
0
votes2
answers81
viewsA: Nodejs - Change the value of a vector in an if Else
This is happening because you are using Else if and not only an Else, as in the two checks (if) it returns false, the params variable returns nothing, because it really has nothing to return. I…
-
0
votes1
answer41
viewsA: I want to click on a little face and just leave it, if I click on another uncheck and leave the new one marked
The logic would be more or less this, before marking what was clicked, clear all, simple and fast. function uncheckItems (item) { item.forEach(element => { element.style.color = "#000000" }) }…
javascriptanswered Lucas de Carvalho 6,427 -
3
votes2
answers224
viewsQ: Take part of the CSS class name
Is there any way to get "part of the class name" in CSS? I say this because of the example: <div class="result_itens_id1255454"> Let’s assume that this id1255454 is random, so there would be…
cssasked Lucas de Carvalho 6,427 -
0
votes1
answer36
viewsQ: Is there an XHTML5?
I ask this question because based on two other questions I did not understand a solution. The first would be this: When to use the xmlns attribute in the html element? In this case, the accepted…
-
5
votes1
answer1150
viewsQ: What is the difference between findByIdAndRemove and findByIdAndDelete in Mongoose?
I’m looking for the difference between the two and I can’t find it. They’re synonymous?…
-
2
votes4
answers194
viewsA: Exchange images with Jquery
This error happens because the element you are selecting to exchange does not have the "src" property or better, you are not actually selecting an element, in case you have to select the img tag you…
-
11
votes2
answers388
viewsQ: Asynchronous return of some Apis
Why the return of some Apis are exactly the result we want (for example, a JSON) and some others return an object full of functions and objects? Example API that directly returns the result I want:…
-
2
votes5
answers3418
viewsA: Check the amount of negative elements in a JS array
A simple way to do this would be like this, using the foreach. It’s as simple as it is, I think it would take you 10 minutes to study your structure. function verifyArray(arr) { let elemNegative =…
-
0
votes1
answer63
viewsA: How to show even numbers from X to Y and remove "Undefined" at the end
All functions in Javascript return Undefined unless specified otherwise. When you from the console.log(myFuncao) you are giving console.log on the function as a whole, as its return will always be…
javascriptanswered Lucas de Carvalho 6,427 -
0
votes2
answers267
viewsA: @keyframes does not work
It actually works, only it goes back to its initial state, not in the state of animation. Place an Animation Duration of some time and note that the animation will work: .brancoTransparente {…
-
10
votes1
answer752
viewsQ: Why doesn’t CORS block Postman and derivatives?
I am creating a Restful API with Nodejs and express and in it, I am using Cors to "control" requests. In the browser works, if I make a request to this API by the console of the site here of…
-
2
votes2
answers160
viewsA: How not to select an element in css?
You can use the not Let me give you an example below: .lista *:not(:nth-child(2)) { color: red; } <ul class="lista"> <li>Um</li> <li>Dois</li> <li>Três</li>…
-
0
votes2
answers55
viewsQ: Set attributes in a single JS block
Is there any way to do this? I’m repeating a lot of code with the setAttribute in a single element, so I’m researching if there’s any way to do this in a more organized and optimized way, but I…
javascriptasked Lucas de Carvalho 6,427 -
0
votes0
answers14
viewsQ: Animation in CSS Enable X in X Time
Is there any parameter for my animation to activate x in x time? For example, every 7 seconds I want this animation to activate: <!DOCTYPE html> <html> <head> <style> body {…
-
1
votes4
answers6855
viewsA: Execute function when losing focus of an input
You can use the . on function as multiple events and use click and Blur to do this: $('.teste').on({ click: function () { console.log('Fui clicado!') }, blur: function() { console.log("Sai do…
-
4
votes4
answers205
viewsQ: Catch event that happened on page
Is there any way to stay monitoring the events that are happening on the page? Any function you leave by registering on console.log for example, I don’t know, it’s just an example.. There’s a way to…
-
2
votes2
answers634
viewsA: Select the first occurrence of the class using css
It does not work simply because . shows not to be the first child of paragraphs, even having the first class . shows. You can use Nth-Child and with it decide the background of it: .oculta {…
cssanswered Lucas de Carvalho 6,427 -
1
votes1
answer440
viewsQ: Add child element before other
I’ll explain: Assuming I have the following code: const filho = document.createElement('li') const text = document.createTextNode('Filho 0') filho.appendChild(text)…
-
1
votes2
answers81
viewsA: Grab an inline style value
Yes friend, you can use clientWidth to return the value of the width of your element. console.log(document.querySelector('li').clientWidth, document.querySelector('li').style.display,…
-
1
votes1
answer88
viewsA: Remove a value from a radio button menu
Since the stars have a fixed value (from 1 to 5) I think it’s unnecessary for you to take this input value, as you already know the values, I think you can store these values in an array and do the…
-
0
votes2
answers134
viewsA: addeventlistener executes a function even before it is called
Where does it have to be clicked? You didn’t set this. Example, suppose you want to click a button: document.querySelector('button').addEventListener('click', function() { alert('Botão foi…
javascriptanswered Lucas de Carvalho 6,427 -
2
votes2
answers795
viewsQ: asynchronous foreach in javascript
Good morning! After breaking my head and not finding the solution, I came to ask Sopt’s friends. It is possible to create an asynchronous foreach? 'Cause the next thing, look at my code: async…
-
2
votes1
answer54
viewsQ: First and second parameter in replaceState
Good afternoon! What is the first parameter in window.hostory.replaceState() For example, in the examples I saw, they always pass an empty object... Could explain exactly how this method works?…
javascriptasked Lucas de Carvalho 6,427 -
0
votes3
answers85
viewsQ: Make item open when giving
Good afternoon, I have a "menu" and instead of being an item inside the other, I am using the ~ to be able to give Hover in the element after which I passed the mouse, then, this element opens, only…
cssasked Lucas de Carvalho 6,427 -
3
votes1
answer131
viewsQ: What’s the difference between Window and Window
A few months ago I’ve been studying Javascript and now that I realize that you have two "equal" objects: the Window and the window. Why are there two and what’s the difference between them? Editing:…
javascriptasked Lucas de Carvalho 6,427 -
0
votes2
answers44
viewsQ: Reduce operation
Follows my code: function yvlcs() { var buttonsYv = []; document.querySelectorAll('.yv-container-ul li').forEach(function (e) { buttonsYv.push(e); e.addEventListener('click', function (e) {…
javascriptasked Lucas de Carvalho 6,427 -
10
votes2
answers2429
viewsQ: What is the logic behind the "days * 24* 60* 60* 1000"?
Reading some things about cookies, always observe the calculation dias * 24* 60* 60* 1000 What is the logical reasoning behind this?
-
0
votes1
answer556
viewsQ: Difference between Gulp and Gulp series
What’s the difference between using one or the other in Gulp v4? Before I did something like gulp.task('default', ['build']); But now of error... AssertionError [ERR_ASSERTION]: Task function must…
-
8
votes1
answer116
viewsQ: Resolve/Reject play role in javascript?
As mentioned in the title, the resolve and Reject of a Promise already "make paper" of Return or yes (depending on the occasion) I need to use the Return? Explaining with code, I could do these two…
-
7
votes1
answer1335
viewsQ: Is it possible to "force" Javascript typing?
In PHP I’m used to creating a function and can declare the types of parameters I want, even knowing that the language is weakly typed, but in JS I can do this? Example in PHP: <?php class Teste {…
-
3
votes3
answers490
viewsQ: How to use foreach in Javascript associative array
I am seeing here that the length of an associative array in JS is reset.. As I access these values then? Example: let myArray = []; myArray['zero'] = 0; myArray['um'] = 1; myArray['dois'] = 2;…
-
1
votes1
answer25
viewsQ: Open dropdown without it being a daughter tag
Good morning guys, I could create a dropdown without it needing to be a daughter tag? I’ll explain with code. We usually do this: .menu-dropdown {display: none;list-style: none;} .menu:hover…
-
0
votes2
answers128
viewsQ: Get answer from callback
How do I pick up/use the callback response here? const arr = ["Lucas"]; function minhaCall(sobrenome, indice) { return indice + 1 + ") " + sobrenome + " de Carvalho"; } arr.forEach(minhaCall) For…
-
0
votes0
answers28
viewsQ: How to set a default value for Javascript parameters
Good afternoon! I won’t go into a system context, not to stretch, but let’s assume the code below: let meuNome = "Lucas" function setNome(meuNome) { return meuNome; } As you can see, I want my…
javascriptasked Lucas de Carvalho 6,427 -
0
votes1
answer108
viewsQ: What is the Data Layer (Data Layer)?
Most of the sites I go to if I use dataLayer on the console, it brings me some information, already others do not... For example, here on Sopt does not bring. I also saw that Google Tag Manager uses…
javascriptasked Lucas de Carvalho 6,427 -
4
votes2
answers160
viewsQ: Different behavior inside and outside the function
Good afternoon! For example, I made a script to redirect all people from my site to the home of the site, because, we will change system and with this, sales have to stop so we can do this. I made a…
javascriptasked Lucas de Carvalho 6,427 -
1
votes2
answers149
viewsA: How to get the Hover to overlap a div with overflow
Buddy, it’s not gonna work. The div .ler is with None display, so no way to .suspensa will appear, to even appear you need to pass the mouse inside the div .ler, as it is with display None, has…
-
1
votes0
answers319
viewsQ: Composer error: SSL Operation failed with code 1
I found some topics in the OS in English but could not solve the problem by la. Any library, Fw, anything in case I try to install with Composer, I get this SSL error. NOTE: I have SSL installed on…
-
1
votes2
answers934
viewsQ: Identify if mouse scroll is rolling up or down
It is possible with Javascript to know if the mouse scroll is scrolling up or down?
javascriptasked Lucas de Carvalho 6,427