Questions tagged as 'javascript'

2
answers

Hide / Show when checkbox is checked or unchecked

How can I check if a checkbox field is checked, and according to its state, hide or show another input field, eg: <label> <input type="checkbox" name="check" /> Clique aqui </label> <input type="optional" n...
asked by 08.12.2016 / 03:16
2
answers

Wait or check append

I have a div that should make a append of some elements and then do a scroll by the end of it. The problem is that scroll runs before append is finalized. The (generic) code looks like this: $("div").append(output); $("div...
asked by 06.04.2017 / 15:28
1
answer

Verify that the person will close the site

Is there any way to check if the person's mouse is going to close the site? With JavaScript, etc ... In the simplest case: if(estaindofechar){ alert("Tem certeza?"); }     
asked by 29.03.2017 / 15:28
1
answer

css is not a function

I have an array of items that I want to change the css in scroll of my Document, when I give console.log() , the items are there, but in the loop to change their style, it gives me the message:    Uncaught TypeError: items...
asked by 06.04.2017 / 17:31
2
answers

Button that scrolls the page up without reaching the top

I have a code that scrolls the page to the top, but I do not want it to reach scrollTop = 0. It is possible that by clicking the button, it just slightly raises the page up, as if I had the keyboard above the keyboard? $(document).ready(fu...
asked by 04.10.2018 / 18:07
1
answer

Doubt about getter in Javascript

I've been studying computed properties of Vues.js that these computed properties use getters and setters too, and studying on get I fell into this sample code on the mozilla : var expr = "foo"; var obj = { get [expr]...
asked by 30.10.2018 / 19:02
1
answer

Differences between Python and JavaScript in relation to arrays?

I'm having a hard time because in JavaScript it was possible to do this: const x = [] x[0] = 1 x[1] = 2 But in Python when I create an empty list and try to make a statement it says the index is out of range. I can work around the append...
asked by 07.10.2017 / 15:52
2
answers

Can you declare a JavaScript variable so that it always has 2 decimal places?

The idea is not to have to convert the result to two decimal places at all times. Example: var preco = 10.00 To show these decimal places, I have to put it like this: $("#preco").html("R$ " + preco.toFixed(2)); And then if I do any cal...
asked by 07.11.2018 / 22:34
1
answer

jQuery / javascript - Skip input when maxlength is reached

Good morning, friends! Next, I want to make a function that if it reaches the maxlength of the input (in the case 2 characters), it jumps to the next input. I made the code below that is not running ... var inputZin = $('.idade-viajante...
asked by 06.11.2018 / 13:44
3
answers

Prevent a value from being selected in the dropdown

Is there any way to prevent a value from being selected in a dropdown? For example: document.getElementById('teste').onchange = function (event){ var valor = this.value; if(valor == 4){ alert('esse valor não pode!'); event....
asked by 05.10.2017 / 22:07