Questions tagged as 'javascript'

3
answers

How to use this!

I need each button when clicked to turn yellow and the others return to normal ... follow the code and the fiddle: $( "#botoes" ).each(function() { $(this).click(function() { $(".botaoativo").removeClass('botaoativo'); $(th...
asked by 21.09.2014 / 21:56
4
answers

How to mix an array in JavaScript?

In PHP, when I need to mix an array, I use the shuffle function. So: $a = array('@wallacemaxters', '@rray', '@CiganoMorrisonMendez'); shuffle($a); print_r($a); output: Array ( [0] => @CiganoMorrisonMendez [1] =>...
asked by 26.10.2015 / 16:57
3
answers

Go to the next element with next and add a class to the previous one

I'm trying to make clicking on the "next" link one of my lists revealed and the previous one being hidden, using a class that has display: none; , tried with .next() of jQuery but there were some problems, such as , for example, in...
asked by 19.02.2014 / 22:28
2
answers

Definition: document.getElementById

asked by 11.01.2017 / 10:49
4
answers

Check for image return via Javascript

How to check if the image returned with 404 error via javascript. Below a sample code, I want to check if the get of this image is 404. If I want to put a certain image, if it does not return the image. <!doctype html> <html lang="...
asked by 03.06.2014 / 19:45
3
answers

What is the use of the colon in JavaScript?

What is the use of the colon : in JavaScript, like the example below: function paciente(nome, idade, altura) { var clazz = { imprime: function() { alert("nome: " + nome + ", idade: " + idade); } return clazz; } I kn...
asked by 15.01.2016 / 23:41
3
answers

Check if a div contains a number

I have a paragraph that contains multiple links, alternating between words or numbers. I need to do the following check: if the link within the paragraph is any text, it will not do anything with the text, but if this link has a number, it will...
asked by 25.02.2014 / 18:39
5
answers

How to use the reduce (reduce) operation on objects?

In Javascript, when I need to do a reduction operation, I use the Array.reduce method. So: var valores = [1, 2, 3, 4, 5, 1000]; var resultado = valores.reduce(function (soma, atual) { return soma + atual; }) console.l...
asked by 13.11.2017 / 12:44
4
answers

How to split a string into specific sizes in JavaScript?

I need to split a string into a specific size in JavaScript. I know you can use Join to turn a string into a array of letters: 'hello'.split('') However, I need a way where I can determine the size at which this st...
asked by 11.08.2016 / 14:59
3
answers

Using 'break' in JavaScript

For example, if I have the following code: var i, j; for (i = 1; i <= 3; i++) { for (j = 1; j <= 3; j++) { if (j === 3) { break; } text += "The number is " + j + "<br>"; } } When using break, it breaks th...
asked by 01.02.2018 / 17:09