Posts by BrTkCa • 11,094 points
375 posts
-
0
votes1
answer66
viewsA: doubts with select and angular Js
Assuming that your HTML structure is this, you can get the text from a previous node using previousElementSibling. Example: var label =…
-
6
votes1
answer3685
viewsA: Function pipe() javascript (Node.js)
The function pipe What you saw in Gulp actually comes from Node.js. The function pipe is part of the Node.js API Stream. Many things in Node.js are Streams, such as HTTP connection, opening files,…
-
2
votes2
answers446
viewsA: Regain marker latitude and longitude (Marker)
You can call getPosition() on the marker, something like that: var marker = new google.maps.Marker({ map: map, title: place.name, position: place.geometry.location }); var lat =…
-
1
votes2
answers255
viewsA: Replace Undefined javascript value
I would suggest you go through the list itself and if you find undefined change the direct value on the object. An example of the list can be: [ {id: 1, mesReferencia: "Jan"}, {id: 2, mesReferencia:…
-
6
votes2
answers583
viewsA: Script js does not interrupt form Ubmit
Remove the return false and put preventDefault to prevent the page from updating: $('#form-add-post').submit(function (evento) { evento.preventDefault(); // corpo });…
-
3
votes1
answer249
viewsA: Grab Dynamic Element in JSON
There is a way yes. First you can find out which is key of the object in obj.installments using for. in. Thus, regardless of what is there (visa, master, etc.) will be saved in a variable. Then it…
-
4
votes2
answers104
viewsA: Receive only number in money field
If the result is R$ 5,00 for example, an initial form may be: var recuperado = "R$ 5.500,10"; var numero = parseFloat(recuperado.split(" ")[1].replace('.', '').replace(',', '.')); console.log(typeof…
-
2
votes1
answer183
viewsA: Google Chrome - Image problem in full screen
To the google-Chrome put this style to allow full-screen: img:-webkit-full-screen { position: fixed; top: 0; left: 0; min-width: 100%; min-height: 100%; } Jsfiddle:…
-
6
votes1
answer329
viewsA: How to summarize a text within the <span>?
You can define the text-overflow as Ellipsis in his style: span { text-overflow: ellipsis; } Example: span { display: inline-block; width: 100%; white-space: nowrap; overflow: hidden !important;…
-
0
votes3
answers1506
viewsA: Formatting numbers with jQuery
I recommend the library jQuery Mask. Your code can stay that way: HTML <input class="money" /> jQuery $('.money').mask('0000.000,00', {reverse: true}); Jsfiddle:…
-
3
votes2
answers181
viewsA: Images in html or via css
One advantage I see is that by CSS the code becomes reusable. If multiple tags img use the same style and it is necessary to change the image path, just change the style that is applied for…
-
6
votes2
answers1025
viewsA: How to disable/enable button(button) when input file is empty/selected?
It is possible to obtain the details of input file by the event change and then enable the button, something like: $("#img").change(function(){ $("#btnEnvia").attr("disabled", false); }); <script…
-
4
votes1
answer3366
viewsA: How to clean input?
It depends on the event it will invoke, but basically it will work for most input. Javascript With javascript it is possible to change the value of the property value:…
-
3
votes1
answer380
viewsA: Display fixed alert independent of scroll position on page
Can change position for fixed, leaving the style this way: .dialogbox { position: fixed; left: 0; right: 0; margin: auto; width: 100%; max-width: 550px; top: 60px; border-radius: 4px; background:…
-
1
votes4
answers177
viewsA: How to get the entire HTML of the last Fieldset into a dynamic page?
You get all the children of the element Blocking and concatenate the contents of those who are fieldset: var fildsets = document.querySelectorAll('#BlocosDinamicos fieldset'); var content =…
-
0
votes3
answers34
viewsA: Line up and put div on the other
I propose to insert a paragraph within the element notifying and set a size for it, such that I left with 90%. So change some things in the classes .notification .overflow-menu and .notification,…
-
3
votes3
answers1464
viewsA: How to change the text of a link after clicked?
With jQuery you can exchange text at the event click of the link: $("a").click(function(){ var texto = $(this).text(); $(this).text(texto == "Mostrar mais" ? "Mostrar menos" : "Mostrar mais"); });…
-
1
votes1
answer203
viewsA: How do I make the button overlap the background image?
Try to use the property z-index: #botao { background-color: rgb(195, 88, 246); border: 1px solid; border-radius: 5px; border-color: rgb(195, 88, 246); padding: 3px 5px; top: 10px; position:…
-
5
votes2
answers89
viewsA: How to make a regex capture a large variation of a term? (HOUSE, House)
You can use: /(casa)/ig Explanation: (word): Character capture group literally /i: modifier for insensitive /g: modifier to global For Java, as @Aronlinhares commented, it should be: (?i)(casa)…
-
3
votes4
answers5749
viewsA: Input type NUMBER does not consider maxlength
You can include a "mask" in the event keydown of input. Something like: document.getElementById("numero").addEventListener('keydown', function(event) { if (this.value.length == 3 &&…
-
19
votes3
answers24684
viewsA: How to browse an object in Javascript?
You can use Object.Keys or for. in to iterate keys and object values: var obj = { "column01": "Coluna 01", "column02": "Coluna 02" }; Object.keys(obj).forEach(function(item){ console.log(item + " =…
javascriptanswered BrTkCa 11,094 -
20
votes3
answers24310
viewsA: How to check if a String is empty in Javascript?
I consider the most practical way: if (!pessoa.nome) Well, go check it out: vazio ("") null NaN undefined false 0 var pessoa = { nome: "" } if (!pessoa.nome) console.log("Atributo vazio");…
javascriptanswered BrTkCa 11,094 -
1
votes3
answers58
viewsA: What’s wrong with this js code?
One option is to remove the accent before checking. With SE6 would be: var str = "Ação" str = str.normalize('NFD').replace(/[\u0300-\u036f]/g,""); console.log(str);…
-
5
votes2
answers939
viewsA: Generate a random profession for Online Players
The ideal would be to explain the way I propose drawing, but I will try to illustrate. To ensure that each player will have a valid role and has only 1 Policeman, 1 Lady and 1 Criminal Let’s imagine…
-
2
votes2
answers352
viewsA: Placing scroll in the horizontal
To enable scroll horizontally you can use overflow-x in the class of the element that can be expanded (example menu_topo_geral): .menu_topo_geral { overflow-x: visible; } Jsfiddle:…
-
6
votes1
answer696
viewsA: Doubt to remove Javascript attributes
You can use the delete operator: var pessoa = { nome: 'Fernando', idade: 15, }; // verifica se nome existe if (pessoa.nome) delete pessoa.nome; console.log(pessoa);…
javascriptanswered BrTkCa 11,094 -
2
votes1
answer39
viewsA: How to simulate [mouseup()] element by element using get()
One option is to get the references of inputs by javascript and, within the loop, call a function to uncheck by increasing the time between executions. Something like: function go() { var inputs =…
-
1
votes4
answers2413
viewsA: Generate angular pdf using javascript
I’m not sure if this can work for you, but it’s the way I download CSV by ajax using Angularjs. You could create a link on the return of the function and associate to the URL the path of the created…
-
5
votes2
answers312
viewsA: How to check an object type attribute in Javascript?
You can iterate the object keys using Object.Keys and check if it is a number using isNaN: var obj = { fernando: { nome: 'Fernando', idade: 21 }, tiago: { nome: 'tiago', idade: NaN }, lucas: { nome:…
javascriptanswered BrTkCa 11,094 -
3
votes1
answer32
viewsA: Changing input border with Javascript
You’re using the wrong getElementsByClassName. And the return is an array, so it must be accessed by the index: var input = document.getElementsByClassName("dado"); input[0].style.border = "2px…
-
1
votes2
answers146
viewsA: Is it possible to change the background color of an element for printing?
You can use Media Query to apply specific styles for printing: /*CSS para impressão*/ @media print { body { -webkit-print-color-adjust: exact;} .cinza{ background-color:#dddddd !important; } }…
-
3
votes2
answers178
viewsA: Fetch content from a td from a class
You can use getElementsByClassName to search for all elements that have this class, then check its contents: console.log(verificarElemento('Óleos')); function verificarElemento(nome) { var tds =…
javascriptanswered BrTkCa 11,094 -
2
votes1
answer49
viewsA: How do I use parse() in javascript?
Date.parse expects a date representation string in format RFC2822 or ISO 8601 (other formats may be used, but the results may not be as expected). In the case of month names, the expected is in…
-
4
votes2
answers768
viewsA: How to make a gradient at the ends of a line, with CSS?
I would make a div with fixed size, leaving the backgound linear gradient: HTML <div class="linha"></div> CSS .linha { margin: 10px 0; height: 2px; background: black; background:…
-
0
votes2
answers1385
viewsA: Overlaid and responsive images
To make images responsive you can use the class img-Responsive. To leave one image on the other, it is possible with z-index, and leave the absolute position in the second image for a div that…
-
2
votes3
answers1936
viewsA: How to pass dynamically changed value to function, in Angularjs
One option is to create these variables in the controller, in the function that fills them and not go through argument: HTML <input type="button" value="Inserir" id="inserir-item"…
-
2
votes3
answers4512
viewsA: How to pass the value of a variable to an Hidden input?
With javascript just assign the value to the attribute value: var variavel = ["a", "b", "c"]; document.getElementById("input_hidden_id").value = variavel.join(""); Example: var variavel = ["a", "b",…
javascriptanswered BrTkCa 11,094 -
4
votes2
answers646
viewsA: Sort Dropdown with jquery after append
You can order save values of options in an array and then sort it. When only the .sort() without arguments, he already understands ascending and alphabetical order. An example: const array = [];…
-
8
votes4
answers1246
viewsA: Identify if all characters are equal
With ECMA6, it is possible using Set: const unicos = [...new Set(numbers)] Example: var numbers = '1111112111'; if (new Set(numbers).size > 1) console.log("Todos os valores não são iguais"); else…
-
6
votes1
answer86
viewsA: How to save to a variable what is typed on the screen
One option is to put one Listener in the document and store in an array the values pressed (or keyCodes) and do a continuous search in that array to check if what it has is what you’re looking for -…
javascriptanswered BrTkCa 11,094 -
4
votes3
answers347
viewsA: Difference between validation and mask
Masks more than formatting a data entry element also validate input type. It may be interesting that a numeric field does not accept characters, for example. Validation refers to whether the data…
-
2
votes3
answers2700
viewsA: JS - Object array for array arrays
Another approach is to use a classic iterator (although I prefer map), read the properties of the object, add in a temporary array to add in the new array of arrays: var array = [{ nomePergunta:…
-
0
votes1
answer52
viewsA: Create array dynamically while typing and deleting when the value is empty?
You can check on change of the input if the property is empty, if yes, instead of using delete, use splice to remove the object from the message array: // indexPai é referente ao index de colums. //…
-
1
votes2
answers393
viewsA: Message to the user in Label with Jquery
jQuery val() is for data entry only. In your case, since it is a label there are various forms, such as html() or text(): $('#MensagemEmail').html(''); $('#MensagemEmail').text(''); There is the…
-
2
votes1
answer705
viewsA: Api facebook does not return date of birth
The only information the Graph API provides without analysis is the public profile, the others need to undergo a review by Facebook, and, if approved, the application will be allowed to obtain the…
-
1
votes1
answer52
viewsA: Limit the Textbox value by taking into account the sum of its values
$("#mySelect12").on("blur",function(){ var valor1 = parseFloat($("#mySelect11").val()); var calc = 100 - (parseFloat($(this).val()) + valor1); …
-
1
votes3
answers2214
viewsA: Add html with jquery
Yes, using append: $(seletor).append();
-
1
votes1
answer217
viewsA: How to directly type the decimals after the user type comma with Javascript?
Regardless of how you are mounting your mask, a simple option is to initialize the field value: $("#js").on("keyup", function(ev){ if (ev.keyCode == 110 || ev.keyCode == 188){ var valor =…
-
1
votes2
answers1391
viewsA: How to format a very large string (organize the text)
A hint is to delimit the size of the output component, leave word markup to break word, block display and align justified. See the result: #conteudo { width: 300px; word-wrap: break-word; display:…
-
0
votes1
answer400
viewsA: Adding items to a list and adding click event next - Javascript
In the example you have, I added the classes (which changes the colors of the item from red to blue) and a function called atualizarEvento, which adds the click event to the last item added in the…