Posts by Lucas Ayrosa • 900 points
29 posts
-
-2
votes2
answers157
viewsA: SUBMENUS HOW TO OPEN ON CLICK
Robson, your code is functional, but if your goal is to open the menu by clicking on the green area, I recommend making the modifications below: $('.oculto').click(function() { $('.meen ul…
-
6
votes2
answers179
viewsA: What better way to check if an object is empty?
You can create a function that will traverse the properties of the object and return the answer. If the is precorra some property of the object, so it is not empty, it will return false. If he…
javascriptanswered Lucas Ayrosa 900 -
3
votes3
answers268
viewsA: How to sort an array of Javascript objects through an object value
Below is a demostrative code. The important thing is to create a sort function, in your case: function dataDecrescente(a, b) { return a.creationDate < b.creationDate ? 1 : a.creationDate >…
-
0
votes3
answers56
viewsA: a line of my object array is missing
The algorithm is working correctly. The Array.prototype.find() it traverses the array and returns the first element it has true as a result of callback. To return everyone who passes on condition,…
javascriptanswered Lucas Ayrosa 900 -
1
votes4
answers87
viewsA: Show/Hide Information by clicking
I made a change to your code that will hide the *** and return to it by clicking on the value. The change was to add the class btn-toggle also in the div of the value and add the data-element…
-
1
votes1
answer42
viewsA: how to compose a fieldset with 2 color themes?
Just put the component template as follows: <fieldset id="fieldset" [class]="tema"> <legend>Informaçoes X</legend> Texto texto texto </fieldset> The component’s Typescript…
-
2
votes4
answers2454
viewsA: How to change the button color of the bootstrap navbar?
The color of the button you must change in the tag class <button>... For example: <button class="btn btn-primary">Buscar</button> It would be interesting if you put all the HTML…
cssanswered Lucas Ayrosa 900 -
1
votes1
answer236
viewsA: Intercept all HTTP requests from angular2
Create an interception class: import { Injectable } from '@angular/core'; import { HttpInterceptor, HttpHandler, HttpRequest, HttpEvent } from '@angular/common/http'; import { Observable } from…
-
5
votes2
answers57
viewsA: Check if a variable is of the function type
Knowing that: typeof xpto // "function" Maybe do: function isFunction(f) { return (typeof f === "function") } Be an option for what you want. I hope I’ve helped.…
javascriptanswered Lucas Ayrosa 900 -
1
votes2
answers46
viewsA: delete jquery
You can create a directive, follow example to make the element darker when the mouse is on it: import { Directive, ElementRef, HostListener, Renderer, Input } from '@angular/core'; @Directive({…
-
1
votes2
answers465
viewsA: Force CSS and JS cache clean
Using PHP makes it very simple, you can create a versioning variable and call it in the query string of the files. For example: Create a variable in a config.php file: <?php define(“Version”,…
-
10
votes1
answer411
viewsA: Why are some Javascript variables declared with underline _?
It’s a convention to say that these properties are private. Below is the link, with examples, of a style guide for Javascript: Naming conventions…
javascriptanswered Lucas Ayrosa 900 -
0
votes4
answers7984
viewsA: How to solve 3-hour accretion problem in Date attribute in Angular?
You don’t have to worry too much about this, since the standard that is being sent to the back end is from ISO 8601. If you take your date and give a console.log(date.toISOString()) you will see…
-
3
votes2
answers42
viewsA: Stop counting for Jquery
What is happening is that your code is looping, since when you have i=3 you decrease it and the continue makes it go to the next loop of the for, where it becomes worth 3 again, and so goes into…
-
0
votes2
answers234
viewsA: How to join two arrays at the angle
You can do it this way: getPhotos(page: number) { this.updateMasonryLayout = true; this.unsplashAPI.random(0 + page) .subscribe( (photos: any[]) => this.photos = this.photos.concat(photos),…
angularanswered Lucas Ayrosa 900 -
1
votes2
answers75
viewsA: Moment.js When working with night dates for the morning
I did the check, if the result is negative, it will add another day (24h) to the result, making the calculation correctly. Follows code below: $("#time2").keyup(function() { var valor =…
-
0
votes1
answer86
viewsA: Hide div with Javascript
Hello, Larck. By the behavior I understood, your code was almost correct. Check if this is the behavior you want according to the code below. Only two minor changes have been made and are commented.…
-
1
votes4
answers180
viewsA: How to remove the last space in each line from a textarea?
Have you tried using the .trim()? It removes all initial spaces and all endings of the sentence. There is also the .trimRight() or the .trimEnd(), both remove only the spaces at the end of the…
-
1
votes2
answers4995
viewsA: How to resolve is not defined at Htmlbuttonelement.onclick
If you are using Angular you should give the instruction to click on your button as follows: <td> <button class="btn btn-primary float-right" (click)="addCart()"> <i class="fa…
-
2
votes3
answers106
viewsA: How to convert HTML comments to HTML code?
You can try with target.replace(new RegExp(/<!-- \[((\/?)\w)\] -->/, 'g'), '<$1>'); Example: target = ` <div class="container"> <!-- [p] -->texto 1<!-- [/p] --> <!--…
-
16
votes1
answer39629
viewsA: Vscode keyboard shortcuts for comments
By default the shortcut for comment in Vscode is the Ctrl+;. You changed the setting? You also have the option to do the same as Visual Studio: Ctrl+K and then Ctrl+C.…
visual-studio-codeanswered Lucas Ayrosa 900 -
1
votes2
answers2054
viewsA: Format Angular Date
Below is an example of component with Imports to convert dates. It is important import, place as preview and instantiate to be able to use Datepipe. import { DatePipe } from '@angular/common';…
-
0
votes1
answer271
viewsA: Object and Like Array search in Javascript to return the Index find
The return always equal to 0 you are having is because of your map() is being done in a new array returned by filter(), which is only an array containing the elements that met the callback…
-
0
votes2
answers47
viewsA: Find sequence in integer value
You can turn the number into a string and split it, creating an array... I created a function that takes an array and converts it to Int (it’s really important that they all be numbers or create a…
-
2
votes1
answer98
viewsA: Close modal when submitting my form
You can put the attributes on the submite button data-toggle="modal" data-target="#modalNovo" as code below. <div id="modalNovo" class="modal fade" tabindex="-1" role="dialog"> <div…
javascriptanswered Lucas Ayrosa 900 -
1
votes2
answers194
viewsA: Why does the code return Nan Hi BMI calculation?
You’re multiplying HTML elements, you must take their value. function calcImc(){ // adicione o .value para cada elemento selecionado conforme as linhas abaixo let peso =…
-
1
votes3
answers149
viewsA: Set the value of a TD using a JS function
To put the value on <td>: document.getElementById('tdQtdUltimaCompra').innerHTML = qtdUltimaCompra The tag <td> does not have a value attribute. What you can change is its content using…
-
0
votes1
answer64
viewsA: Associate Label in If
It would be good to include the HTML code in your question for the preview to get better. I hope the code below helps and is what you want. Note: Preferably always using id in tags and selecting by…
-
1
votes2
answers107
viewsA: Javascript + HTML return in a field
Thiago, I made some changes to your HTML code, adding label tags related to radios to improve usability (For attribute of the label with value equal to the Radio Id attribute). I changed the value…