Questions tagged as 'javascript'

2
answers

What is the function of the function in jQuery and what is the correct way or time to use it?

Whenever I go to work with jQuery I simply create: $(function() { }); Because it was the first form I learned, at first I thought it was an "int main ()" pattern in C, but then I came across other shapes like: $( document ).ready(functio...
asked by 16.10.2017 / 20:45
3
answers

What is the best way to select an option by text and not by value in jQuery?

I have a select and would like to select a value according to the text of another field that the user clicked on. For example. When I click on a "p" tag with the text "April" I want to select the "April" text option in my select: <select...
asked by 24.02.2014 / 15:34
2
answers

What is differential inheritance?

I was reading this article in the English SO and I came across the term differential inheritance . What exactly is differential inheritance? Is it possible to have a minimal example, preferably in JavaScript?     
asked by 28.08.2014 / 21:55
2
answers

how to represent a monetary field with semicolons in javascript jquery

I have a huge doubt. I need to get the values that are in the database with decimal places of 3 (for example: 56826.497) and display 56,826,497 on the screen. I already tried using maskMoney and priceformat , but they did not work. mas...
asked by 08.12.2014 / 12:06
1
answer

Validation configuration in dynamic fields

I have a problem that is as follows, I have the fields: Name, Age and Text; In a part of the system I register that the Text field will only appear if the Name field is equal to PH and the Age field has the value 20 with both tr...
asked by 21.05.2015 / 20:36
1
answer

JavaScript generating float with several decimal places

When creating an ordering system (quantity x value) I noticed that in some cases when adding broken values, JavaScript returns numbers with many more decimal places than expected. Example: (123*1.23)+(312*3.26) //retorna 1168.4099999999999...
asked by 17.08.2014 / 21:18
2
answers

What is the correct way to stop a "for" loop?

Let's say I have this for loop that works based on my array name: var nomes = ["Nome 1", "Nome 2", "Nome 3"]; for(i = 0; i <= 2; i++) { if(nomes[i] == "Nome 2") { console.log(nomes[i]); console.log("Stop!");...
asked by 12.05.2015 / 19:41
4
answers

Error net :: ERR_BLOCKED_BY_CLIENT when requesting Ajax

I came across a strange error when I tried to run an ajax request, and I was not very successful in finding solutions. Here is the error: Line199offorms.jsis$.ajax({in:$.ajax({type:"POST", url: _url, cache: false, data: {...
asked by 10.03.2014 / 21:06
3
answers

Function as parameter in functions in jQuery

I always used some functions without really understanding what was happening and where these parameters came from. I say the following: Example 1: $("#link").on("click", function(event){ event.preventDefault(); }); Example 2: $.get...
asked by 22.01.2015 / 12:27
1
answer

Download text from a textarea as a file without server-side language

I need the user to click a button to download the text text as a JSON file, for example: User clicks the button - > Begins downloading file textarea.json An example that best expresses: downloadFile(document.querySelector('...
asked by 21.04.2014 / 14:45