Posts by Sam • 79,597 points
3,121 posts
-
1
votes1
answer360
viewsA: Date calculation: today’s date, new date() and date extracted from Googlespreadsheets
Just convert the value from the spreadsheet into object Date(): var dFim = new Date(values[i][5]); With both objects, you don’t have to divide by 86400000 to see if it’s bigger than 0, just check if…
-
1
votes2
answers182
viewsA: Alert does not appear
I see 2 basic problems in the code: 1) If the billet box is checked, it will never reach Alert because Return closes the function. And even if it does, it will generate an infinite loop, because…
-
1
votes1
answer259
viewsA: Problems with closing and opening Modals Bootstrap - Asp.net MVC windows
It is using 2 repeated functions with the same name, but each one dealing with a different modal: bindForm() and openmodal() When you declare a function, it goes to memory. If you redeclare the same…
-
0
votes2
answers1144
viewsA: Change the color of menu items when hovering the mouse
Just change the last selector nav#menu a:hover for nav#menu li:hover a. This will point to the tag a that is inside the li. And change the properties of li and of a so that the link occupies the…
-
9
votes3
answers1089
viewsA: Function - show password!
Can do with CSS only: .show_key{display:none;} [name=senha]:focus + .show_key{ display: block; } <input class="input" name="senha" type="password" placeholder="Digite a senha" value="">…
-
1
votes2
answers102
viewsA: Autocomplete form and check in JSON if it exists
With some functions you can complete the field #nome according to the CPF typed and when submitting the form, verify that the data are correct (see explanatory comments in the code to understand). I…
-
0
votes2
answers110
viewsA: Pick dynamic variable
You are doing wrong by placing a function inside a loop for. This tie seems to me to be quite unnecessary, including. Just use the normal function and concatenate the argument i in id of the…
-
3
votes1
answer1317
viewsA: Bootstrap jQuery UI completion in the background
Put a z-index: 1050 in class .ui-autocomplete, which is the class of ul from the autocomplete list. Just insert into the CSS: .ui-autocomplete{ z-index: 1050; } Depending on the order of the CSS…
-
2
votes1
answer532
viewsA: Stopwatch running from the first second
The problem is that when executing the script the element #sessao has not yet been included in the DOM. Thus, in the first second the function did not find the element. After the first second the…
-
1
votes3
answers37
viewsA: Add values after a separator
Use no more .bind because it has become obsolete since the version 1.7 jQuery and was removed from version 3.0. A hint to get the value is to use the method .replace(). Just use as a single argument…
javascriptanswered Sam 79,597 -
0
votes1
answer112
viewsA: How to pass array values via AJAX, via POST?
Create an array by traversing name, checkboxes marked and send as value in 'areas'. At the beginning of the function put: var areas = []; $("[name='areas[]']:checked").each(function(i,e){…
-
2
votes1
answer58
viewsA: Rotate spans in the LI
Create a property block for spans that do not have the class .vertical, adjusting to the center of the li. Note that some properties declared in this new block do not need to be repeated in the…
-
0
votes1
answer647
viewsA: How to AJAX WITH JQUERY sending a POST?
Use the ajax options method (v1.9+) or type (up to v1.8) with the value "post" and send the value via data: $('#agenda_profissional_online').datepicker().on('changeDate', function(e){ var agendaData…
-
2
votes1
answer58
viewsA: Two arguments within a Javascript function
I suggest you create a pattern for the id’s, where one would be #data1 and another #data2, for example, and not #data11 and #data12. It would be easier to use the same block of code by changing only…
-
1
votes1
answer34
viewsA: Problem calculating and displaying price (R$) per person
2 problems in the code: 1) The .each jQuery does not accept $(this) with Arrow Function: Or do you use function() with $(this) or takes the second argument (which is the loop element) using Arrow…
-
0
votes2
answers74
viewsA: Remove dynamically created button
Just put an attribute onclick calling a function and sending the this (the this represents the element itself, you do not need to send the id button): $("#divina").append("<button…
-
1
votes1
answer154
viewsA: Get generic input field checked with jQuery
First repeat id’s is already wrong. There are numerous ways to select checkboxes. The most common is by a class. The code below returns a nodelist with all checkbox with class .nomes:…
-
0
votes2
answers54
viewsA: Vertical distance between LI’s
Convert the ul in flexbox and use flex-basis: 100px; (where the value 100px is a value that will accommodate the li's within the ul, for the flex-basis allows reduction if the sum of all widths li's…
-
0
votes2
answers89
viewsA: Li s leaving UL
Just one transform-origin: 100%; or transform-origin: right;, which is the same thing. This will make the element rotate with the fixed right side, avoiding extrapolating the area of the ul:…
-
2
votes2
answers1250
viewsA: How to close menu by clicking outside or anywhere on the page?
You can check if the click originated from outside the sidebar by creating a Event Handler to the window object when any element of the page is clicked (see explanatory comments in the code):…
-
0
votes1
answer358
viewsA: sweetalert inputs
Can use a if to check if any of the fields are empty before returning array: if(!resolution || !date || !end_time) return false; If any of the fields is empty, it will return false and the modal…
-
0
votes2
answers78
viewsA: I can’t use quotes on a function value"Uncaught Syntaxerror: Invalid or Unexpected token"
Use single quotes to delimit the attribute and double quotes in the function, the one going in the string must be escaped: function muda(x){ document.getElementById('campo').innerHTML = x; }…
-
0
votes1
answer38
viewsA: When loading page, open first tab with results
As discussed in the chat, just search the tabs for the first different value of 0 on the tag <sup>: <li class="active"> <a data-toggle="tab" class="nav-link" href="#basic"> Basic…
-
0
votes2
answers168
viewsA: Modal closes even clicking on it
You are using the wrong class in the div inside the modal: instead of class="data-content", the correct is class="modal-content": Note that your modal is not even being rendered correctly: it is…
-
2
votes1
answer157
viewsA: Input Mask not working in mobile version
Exchange the onkeypress for onkeydown. Apparently the keypress is not recognized on mobile keyboards. function formatar(mascara, documento){ var i = documento.value.length; var saida =…
javascriptanswered Sam 79,597 -
1
votes1
answer332
viewsA: How to set decimals in JS?
First you’re calling the function somar() within the loop .each, which will cause problems. The function should be called after the loop, when the values have been calculated. Then you need to use…
-
2
votes3
answers162
viewsA: How do I validate an input as its content changes?
You have another event attribute that calls the function as you type in the field, which is the oninput: function teste(){ var input = document.getElementById("input").value; if(input == 5){…
javascriptanswered Sam 79,597 -
2
votes2
answers298
viewsA: How to overlay flex items during a CSS Hover?
Place each form element inside a flex div with a fixed height. In the example below I put 55px of height. You can also create a class for each div to adjust the spacing between one element and…
-
0
votes2
answers110
viewsA: How to prevent function modifies global variable?
You can use the method .Slice(0) which will create a new array from the first without changing the first: var a = ["oi","tchau"]; function duplicar(c){ var b = c.slice(0); b[0] = b[0]+b[0]; b[1] =…
-
3
votes1
answer69
viewsA: Relation between selects
That’s why you’re not pointing to the select.tecidos of the same line. When using $('.tecidos').append(...) you are pointing to the first element of the page that has the class .tecidos (in the…
-
1
votes2
answers46
viewsA: Why aren’t the images glued together?
Probably the width of the images are smaller than the 70% that you defined. With this it does not occupy the entire width of the div, leaving a space on the right. You can solve this by adding the…
-
2
votes2
answers144
viewsA: Display None on label calling by ID does not work in Safari browser
Instead of hiding the input, use another property in conjunction with the visibility: hidden: position: absolute; Both properties have support in prehistoric browsers. So the input will not take up…
-
0
votes3
answers100
viewsA: Change position HTML element with each (or other hint) on page load
To rearrange downwards according to the numerical value of the text, you can use in addition to the .each(), the .sort(). This way, it does not matter the amount of spans in Divs: $(function(){…
-
1
votes3
answers49
viewsA: Validate form and send email
Place at the end of the event function click a Trigger of submit: $(this).closest("form").submit(); How are you using return in all validations, this line above will only be executed if it passes…
-
2
votes2
answers86
viewsA: Selector does not accept value=""
Instead of using the selector select[name=cities], use the same selector id of the select you are using to fill it, which is #cidadesSelect. You can do it two ways: Pure Javascript:…
-
2
votes2
answers179
viewsA: Span within Headings H1...H6
To W3C standard for elements h1-h6 indicates that they may contain phrasing content as child elements, which includes the span. In the documentation of span, including, indicates that the tag has no…
-
6
votes1
answer131
viewsA: code-prettify does not work with linear code (a single line)
I made an indenter from scratch that worked on your Jsfiddle example and some other tests I did. It works as follows: Tag <xmp> initially empty and create soon after it a hidden div and put…
javascriptanswered Sam 79,597 -
3
votes2
answers70
viewsA: How to check the absence of a pointing device on the page on desktops?
There is a Javascript API called matchMedia() that returns an object Mediaquerylist with a boolean property matches returning true if it meets the specified media string or false otherwise. In the…
-
5
votes2
answers70
viewsQ: How to check the absence of a pointing device on the page on desktops?
In a project that aims to work only on desktop devices (desktop PC or notebook) it is mandatory to use a mouse (or pointing device, which can be a touchpad). If the user accesses from a mobile…
-
2
votes1
answer59
viewsA: Duplication of jQuery event
This happens because each time you load, a new one is created Event Listener $(document).keydown in memory, and accumulates. In the case of the button this does not occur because it calls a function…
-
2
votes1
answer1563
viewsA: Add or Remove Inputs with JS
Just create a function that does the calculations and call it when you add or remove lines. The function will calculate the values of the visible inputs and place the subtotals in the respective…
-
0
votes2
answers22
viewsA: Function - Change date format on blank form X
If I understand, just put one if checking whether the value of data has something and execute the rest of the code. If it is empty, it does not enter the if and does not execute the rest of the…
javascriptanswered Sam 79,597 -
1
votes2
answers81
viewsA: Change the result of a TD value for a dynamic table image
You can do it this way (see comments in the code): // seleciona as TDs var cols = document.querySelectorAll("#minhaTabela td"); // percorre as TDs for(var x = 0; x < cols.length; x++){ // pega o…
-
2
votes5
answers9010
viewsA: How do I multiply an array within a function in JS?
You can use the for classic which is also compatible with Internet Explorer 11: function produto(v){ var res = 1; for(var x = 0; x < v.length; x++) res *= v[x]; return res; }…
-
5
votes2
answers185
viewsQ: What is the relation of the <figure> tag to the main stream in HTML?
Reading about the tag <figure> I found this text in MDN documentation: The HTML Element <figure> represents the independent content, often with a caption (<figcaption>), and is…
-
3
votes3
answers220
viewsA: Why "Domcontentloaded" only works after Ctrl+F5
Use the event function readystatechange and execute the code only when the return of the event is equal to complete (means the page has been fully loaded, including asynchronous items such as images…
-
1
votes1
answer51
viewsA: How to fade more than one element in the result of an Ajax
Append with the hidden elements (adding display: none with replace), and then do the .fadeIn() items that have been added to the list: View comments in code: $(".SeeMoreGame").click(function(){…
-
2
votes1
answer499
viewsA: SlideToggle() effect to open horizontally + Jquery (horizontal menu)
jQuery slide effects are only applied to height element, that is, vertically. To use the same effect horizontally, use the animate with width: 'toggle': $(document).ready(function(){…
-
1
votes1
answer44
viewsA: Focus on minutes in time type input
Is there any way to "focus" the minutes of a team-like input? Programmatically does not exist. By focusing the element input time, the first value (representing the hours) is automatically selected.…
-
3
votes3
answers72
viewsA: Add class and remove
You can do that by taking the index of the clicked element and apply to the same index of the list element using the method .eq(índice) jQuery: $('.suite-internal-link').on('click',function(e){…