Posts by dfvc • 514 points
24 posts
-
2
votes1
answer91
viewsA: In CSS and HTML how can I leave side by side?
I believe that the simplest way to achieve what you want is to use flex. Basically you have to put your html code in a div that you have display: flex defined. Then each of the columns has a class…
-
1
votes2
answers42
viewsA: How can I draw an X number without repeating it in JS?
I suggested creating an array with all possible numbers to be drawn. Then remove it from that array and add it to a new one with the numbers drawn. When using length to array to get the random index…
javascriptanswered dfvc 514 -
0
votes3
answers33
viewsA: Why image is not adjusted column in bootstrap
The image is not occupying the entire width of the second column because the columns have, by default, a padding left and right. I see you were careful to remove this padding, adding the class…
-
0
votes1
answer35
viewsA: Do you have a problem having nested fans? | Events with Javascript
From my point of view there is no problem in nesting the listeners Event. However, I would make using "Event delegation" Pattern. Basically it consists of registering the listeners in elements that…
-
2
votes2
answers70
viewsA: The created element does not take javascript functionality
The Event listeners dragstart, drag and dragend are registered only for existing card elements in the DOM. When new card elements are added to the DOM, they do not have any registered Listener Event…
-
0
votes1
answer31
viewsA: Problem when closing menu
Basically you have to register the click Event on the body of the document and check if the clicked element is inside the offcanvas. This translates into a recursive function isElementInOffCanvas…
javascriptanswered dfvc 514 -
1
votes3
answers38
viewsA: How to apply style to a group of selectors
Alternatively to the answers already given, you can choose to select only the first child element by going over your father. Something like: .container:hover div:first-child { background-color:…
-
1
votes1
answer47
viewsA: Change PHP/Html color
Try something like: <td <? if ($linha['Robo PUT'] == 'Montar'): echo "style='color: red;'"; endif; ?>> <?= $linha['Robo PUT'] ?> </td>
-
3
votes1
answer30
viewsA: jQuery Animate() with unwanted behavior
So that the overflow function as expected, it is necessary that the div has the set height. However, you cannot set a static height because it varies according to the content (text) and eventually…
-
1
votes1
answer48
viewsA: How to use a function for multiple Javascript vanilla Ivs?
According to the HTML specification, the attribute id must be unique in a document. getElementById assumes this to be true and therefore only returns an element - the first that you find of the…
-
0
votes1
answer72
viewsA: Uncaught Typeerror: Cannot read Property 'num' of Undefined at Htmlanchorelement.addItem
The estate length of an array returns its size. However, its indexing always starts at position 0, which means an array whose length be 3 has indices 0, 1 and 2. Thus, the error happens because you…
-
1
votes1
answer220
viewsA: Increment values in objects
You can make a small loop and distribute the diff value. Anything like: for (var i = 1; i <= diff; i++) { mail[mail.length - i].value ++; }
javascriptanswered dfvc 514 -
1
votes1
answer24
viewsA: How to prevent the focusout event from firing when minimizing the browser?
I think the only way to prevent this behavior is by using a control flag. See the following example: let windowFocused = true; $(window).blur(function(){ windowFocused = false; });…
-
0
votes1
answer22
viewsA: How to superimpose and center one image to another?
To achieve the overlap as you want, you must position the logo absolutely on the image, having as its relative element its Rent. I added the missing css. Please check. body { background: black; }…
-
0
votes3
answers43
viewsA: personal as I add an image in the background by javascrip?
I think this is what you want... In the following code an object is defined backgroundUrlsPerHour where each key represents an hour and its value is the url of an image. You can add more entries to…
-
2
votes4
answers208
viewsA: How to get an index() of an array with the same element multiple times?
It all depends on how you structure your HTML code. One way is to define each letter in an independent element so that it can record events in each letter and execute logic to exchange the letters.…
javascriptanswered dfvc 514 -
1
votes3
answers114
viewsA: How to remove only spaces between words/letters?
If you want it to exist at all times one space at the beginning and another at the end, you can simply concatenate the spaces with what you tried, i.e., " " + str.replace(" ", "") + " ".…
-
0
votes1
answer24
viewsA: How to place a button that is in the form and in the same row in a table column?
The simplest way would be to apply display: inline-block; form. Once you are using bootstrap, simply apply the class d-inline-block in the form. I also agree with @balexandre’s suggestion, but would…
-
0
votes1
answer37
viewsA: Filter objects within a hashed array
Some things in your code are not correct, such as: The way you’re doing the filtering; The verification (if) if the new item already exists; The way you are adding to the array. I changed these…
-
0
votes2
answers52
viewsA: Problem with "see more" (button)!
One option would be to use the target click to identify the clicked element and then add/remove (using the classList.toggle) the class mostrar. See the following example:…
-
1
votes1
answer22
viewsA: Change color of div by hovering over
If you want to always change to the same color (blue, for example), I would suggest doing it with css, that is, set a class for the squares that are added and then set the css for when you go over.…
javascriptanswered dfvc 514 -
0
votes3
answers44
viewsA: I want the main tag not to be affected by the margin
Try changing the css of the element p for: p { padding-left: 250px; padding-right: 250px; }
-
2
votes1
answer26
viewsA: Arrange Loadbar in Circle
One hypothesis would be to use css to run the element. Anything like: circle { transform: rotate(-90deg); transform-origin: center; } Here’s the code with the change I suggest: var circle =…
-
2
votes2
answers193
viewsA: change color of various elements with the same id with javascript
Another solution would be to add/remove a class at the top level that indicates whether dark mode is active or not. The idea is to use this class to change the css properties that change in…