Questions tagged as 'javascript'

8
answers

How to format date in javascript?

I want to play the current date in an input, but in the "Brazilian" format dd / mm / yyyy. My code: var data = new Date(); dataFormatada = ????? $("#Data").val(dataFormatada);     
asked by 19.02.2014 / 18:54
2
answers

What's the difference between $ (document) .ready () and window.onload?

Is there a difference between $(document).ready() e window.onload plus one being JavaScript and the other being jQuery? I see that both events are triggered as soon as DOM Document Objects) is loaded. In practice as written:...
asked by 08.02.2017 / 13:17
3
answers

How do I get the value of the current percentage of an upload?

I'm working with PHP , but I imagine this can only be done with javascript/jQuery . When I upload the browser shows the percentage in the status bar. I'd like to take this value and create a custom progress bar from it. The bar I...
asked by 19.12.2013 / 16:42
6
answers

Use a semicolon at the end of lines in javascript?

I've read some web comments about whether or not to use ; at the end of the lines when writing JavaScript. Some say yes, others say they have no need, but none can explain the reasons for the divergences. Example: var ola = "Olá"; //...
asked by 31.01.2014 / 01:18
3
answers

Why use getElementById if the id is in the window?

Recently in my study I noticed an object that manipulated the DOM of the element that had the same name in its id . teste.style.border = '1px solid #CCC'; teste.style.width = '500px'; teste.style.height = '50px'; <div id="teste">...
asked by 13.04.2016 / 14:23
1
answer

What is the difference between using return false, event.stopPropagation () and event.preventDefault ()?

In a jQuery event handler, you can use return false , event.stopPropagation() and event.preventDefault() (or combinations thereof) to "cancel the action" of the event. I know it has a difference in their behavior, but hone...
asked by 12.12.2013 / 12:02
2
answers

How to actually learn how to use promises in javascript?

I've been trying to learn how to use promises and asynchronous programming in javascript for a while, but so far I have not had much success with it. I have already understood that there are functions that return such promises and that a callbac...
asked by 24.05.2014 / 02:28
6
answers

What's the difference between declaring an array with "array ()" and "[]" in JavaScript?

In JavaScript we can declare an array in two ways: var matriz = new Array(); and var matriz = []; What is the difference between the two and what are their consequences? This question is being posed for the purpose of documenting...
asked by 04.03.2014 / 21:48
4
answers

How do I set a "horizontal menu" at the top of the window when scrolling the page?

I have a layout with a horizontal navigation bar at the top of the site, it has margin-top:100px , when scrolling the page the menu should be set at the top of the window but with margin-top:0 . What is the best way to accomplish...
asked by 04.02.2014 / 16:51
3
answers

Should we validate function parameters?

In languages like Java, the method parameters are "validated" in the compilation (at least the type): public void facaAlgo(String str) { // ... } // em algum outro lugar: int i = 2; this.facaAlgo(i); // erro de compilação! In dynamic typ...
asked by 02.12.2014 / 12:46