Posts by Sam • 79,597 points
3,121 posts
-
1
votes2
answers49
viewsA: Remove class when resizing
The problem is that you are nesting events, which usually one should not do. Why? Because when you call one will accumulate in memory the other. What you should do is use both events at the same…
-
4
votes3
answers268
viewsA: How to sort an array of Javascript objects through an object value
Use the method .sort() converting the value of creationDate on date: const api = [ { requestedCase: { creationDate: "2020-01-31T13:49:22" } }, { requestedCase: { creationDate: "2020-01-31T13:48:02"…
-
2
votes4
answers1011
viewsA: Replace a string’s letters with their respective alphabet position
Can use .map(), but it takes some adjustments, as in case there are spaces in the sentence, eliminate them with replace: frase.replace(/\s/g, ''); The expression /\s/g search all spaces. Another…
-
1
votes1
answer42
viewsA: ajax or Ubmit work in a page loaded in . load()
It doesn’t work because you’re putting the tag form in the wrong place, enter closing tag </thead> and the opening tag <tbody>: </thead> <!-- ESTE FORM QUE ESTOU ME REFERINDO…
-
3
votes2
answers44
viewsA: Function in onpaste
Use oninput in place of onkeypress sending the element as a parameter to the function through the this: oninput="SomenteNumeros(this)" The advantage of oninput is that it detects any changes in the…
javascriptanswered Sam 79,597 -
2
votes2
answers107
viewsA: Duplicate Jquery event in ajax call
Use the method .one() in the jQuery of the aquivo Estoque_filter.html. It fires the event only once and then removes it. So it will not stack events: $("#altera").one("click", function(){ $.ajax({…
-
2
votes2
answers54
viewsA: Insert from a table with for
You have a problem with your code relative to the selectors when using ^= to catch name's started by the string Tipo. Look at these two lines: $("input[name^='Tipo1']") $("input[name^='Tipo']") The…
-
1
votes1
answer80
views -
0
votes2
answers141
viewsA: Change color of div in onclick event - JS
The self cannot be sent as a parameter to the function because it has nothing to do with the context. See the topic below: Javascript - Difference between this and self What you have to send is the…
javascriptanswered Sam 79,597 -
2
votes1
answer464
viewsA: Taking value from a hidden column of datatables?
When Datatables is rendered, invisible columns are completely deleted from the DOM, therefore being inaccessible via common Javascript. You need to use the component API, that is, the method Row().…
-
3
votes1
answer222
viewsA: How to perform an action when finishing each() Jquery
The implementation of the Code will only continue after the completion of the $.each(). That is, the next line after the $.each() shall be executed only when the $.each() finalize:…
-
0
votes2
answers75
viewsA: Width changing unlike function logic
The problem is that the property .style.width does not take the value of the property width defined in CSS. It returns the value that is in the attribute style of the element: <div style="width:…
-
1
votes1
answer216
viewsA: Ajax function running multiple times even being called only once
Putting onclick="addItemCom()" on the Submit button, each time the function is called will create in memory an instance of the event $('form').submit, so you’re multiplying the event trigger. It is…
-
2
votes1
answer122
viewsA: How to use a variable declared within a function, in another function?
The variable declared with var within a function will only have scope within that function. As it is explicit that you want to assign a value to the variable cpf when calling the function where it…
javascriptanswered Sam 79,597 -
10
votes7
answers16899
viewsA: How to create a <select> with images in the options?
As already said, the option is an element that does not accept images. I have developed a jQuery code with CSS where you can replace the select by an HTML list that will simulate select. The code…
-
1
votes1
answer139
viewsA: How do I bring records from the database by clicking on the checkbox using jquery and ajax?
Create a function for AJAX and send as parameter the information coming from a checkbox checked. For example, AJAX is inside the function checkFiltros(), would look like this: function…
-
2
votes1
answer142
viewsA: Show success alert with sweetalert2
From the version 8.0.0, the function swal() became Swal.fire(), as you can see in this official documentation: You are using the version 8.11.8.…
-
3
votes3
answers204
viewsA: Is it possible to save a used browser object localstorage?
Yes, it is possible to save the data in the browser with localStorage. Saved information is stored permanently in the browser until you delete it. To delete what was typed in the input after…
-
2
votes1
answer143
viewsA: Sort by quantity properties with different javascript names
There is no way to reorder Javascript object properties. What you can do is use the method .sort() to create an ordered array and then create a new object in the order you want. See a user’s comment…
javascriptanswered Sam 79,597 -
1
votes1
answer126
viewsA: Scroll horizon on Nav-tabs component (bootstrap 4)
You can use the method .animate() jQuery, but you need to use the full version of the library. In your code you are using the slim version, which does not have the .animate(). Just replace the…
-
1
votes2
answers112
viewsA: Changing table values using UPDATE CASE
First you must put the values in quotes (except the numeric ones). For example, instead of nome = carlos, use nome = 'carlos'. And to change the two columns (nome and ativo) you make two CASE, first…
-
1
votes1
answer57
viewsA: Change another class (CSS) noscript
First thing is that the element ul can only have as direct children elements li, that is, you cannot tag a as the direct son of ul. It would have to be like this: <ul> <li> <a…
-
2
votes1
answer62
viewsA: How to make arrays go from one to one?
You don’t need a bow for. With only setInterval you already can. Just go through each index of the array to the end. When the variable value indice is equal to the size of the array, cancel the…
javascriptanswered Sam 79,597 -
2
votes1
answer31
viewsA: Jquery Setinterval with incorrect speed when clicking
The problem is that every click on one of the buttons are being created several instances of setInterval and will never access the else where the same is canceled, because you are declaring the…
-
2
votes1
answer72
viewsA: How to put 2 background-image being one of them semi-transparent
There is no way to apply opacity to background-image. In this case you could create a pseudo-element ::before floating and applying opacity to it. It is also necessary that all elements within the…
-
0
votes1
answer35
viewsA: How to direct a link to one of the tabs of a Bootstrap 4 list group
You can trigger a click on the tab link automatically: var url = location.href; var string = url.split('#'); var valor = string[1]; $("a[href='#"+valor+"']").click(); // dispara o click Note that…
-
0
votes2
answers2311
viewsA: CSS - H1 Does not align in the center
Dude, your problem is you’re setting a fixed width on your h1. With this it will be aligned to the left, which is normal with all elements. The element h1 is a block element that occupies by default…
-
0
votes2
answers1775
viewsA: By clicking the scroll down button to the end of the div
The Sweetalert box should normally appear above the modal, since it is created at the end of the body, as shown in the print below: If in your case the alert is getting below the modal, it may be…
-
1
votes1
answer50
viewsA: onclick with . append sending function with variable
It turns out that you are passing to the function a text string without quotation marks: onclick="liberarCarro(eVzsQHCk4UozJ4MQI26S)" ↑ sem aspas delimitadoras In this way, what is sent to the…
javascriptanswered Sam 79,597 -
0
votes1
answer34
viewsA: Use of pseudo-elements ::after in a DIV simulating an INPUT with LABEL - Pseudo-element overwrites the cursor. How to do not overwrite the cursor?
Place z-index: -1 in the ::after that he will be behind the cursor. See without the z-index (note that the cursor is behind the text): Now with the z-index, note that the cursor is focused above the…
-
0
votes1
answer41
viewsA: Insert image aligned with <h>
You can position the image absolutely inside the header. Just put the image as a child straight from the header and add property position: relative; in the header and position: absolute in the…
-
1
votes1
answer84
viewsA: Return range of numbers according to the division of total numbers by an integer
Can use .slice() to slice the array according to the number of people (second argument passed to the function) by inserting into a new array the values in each index of that new array. It would be…
-
1
votes1
answer41
viewsA: Width auto with the second element filling the remaining space
Use display: flex in the main div and place flex: 1 in the field. Note that I have eliminated some properties, such as the float: left and the width field and label. The flex: 1 causes the element…
-
1
votes1
answer77
viewsA: Modal with id=Undefined
See this excerpt from the code: var button = $(event.relatedTarget); var id = button.data('service'); The first line you take the button that opened the modal. In the second you are trying to get…
-
5
votes1
answer73
viewsA: Change style of repeated classes differently with CSS
Just use a different selector pointing to the class .teste within the class .tal2: .teste{ color: red; } .tal2 .teste{ color: blue; } <div class="tal"> <div class="teste">texto…
-
0
votes1
answer78
viewsA: two onclick events in the same loop
When creating the function reset() within the loop, and it is superscripted resulting in the variable i at the last value after the for have finished, that is to say, i will equal 3, soon,…
javascriptanswered Sam 79,597 -
1
votes2
answers47
viewsA: how to save user’s choice in a Nav-tab modal
One way is to create hidden fields (type="hidden") within the last form (the form that Submit will take). Each input field will have one name corresponding to each option of the buttons clicked on…
-
2
votes1
answer49
viewsA: Problems with Progress-bar in Flip card
Add right: 0 in class .flip-card-back. As the back is reversed by 180 degrees, the orientation of the element will be opposite (right to left). Aligning the back to the right with right: 0, there…
-
2
votes2
answers73
viewsA: Two functions in the same javascript onclick event
The event onclick will only be fired if you click and drop. With this, the document.addEventListener("mousedown"... will only be created if it happens at least once. Call the function ambienteEdit…
javascriptanswered Sam 79,597 -
1
votes1
answer356
viewsA: How to load a value into a DIV after selecting an option in the dropdownlist of an input text that uses Typeahead and Ajax?
Instead of using $.map, use $.each to iterate the returned JSON, creating an array with the product names and populating an object with a key related to the image name, for example: { "Tenis Nike":…
-
0
votes3
answers92
viewsA: Optimize adding events to various Javascript elements
Instead of using id’s in sequence, I would suggest using class. So you’ll just need to put the same class on each button and another class in each element you want to show, and to search within that…
javascriptanswered Sam 79,597 -
1
votes1
answer175
views -
2
votes2
answers58
viewsA: property order does not work
The estate order would work in flexbox elements. A div .conti that has both Divs with order could have the property display: flex and in your case, another property, flex-direction: column;, to…
-
3
votes1
answer39
viewsA: @media does not change content
Missed putting the meta viewport in the head. For example: <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=yes"> The options of content you arrow what best…
-
1
votes1
answer244
viewsA: CSS inverted curtain effect
Just change the top for bottom in transform-origin for the purpose of down instead of up-down and add property background-color: rgba(0, 0, 0, 1); in the hover of ::before so that the background…
-
6
votes4
answers985
viewsA: Compare string with array to return the most compatible item
One way is by using two .forEach(): the first in the array with the phrases and the second nested in the string array. Then it tells what has more occurrences and compares with a variable that…
-
0
votes1
answer67
viewsA: Event when updating a table
Create your own function for this. For example, create the function: function habilitaBotao(){ $("#botao_novo_sensor_entrada").prop("disabled", false); } And call her on initComplete (without the…
answered Sam 79,597 -
0
votes2
answers236
viewsA: Changing the label of a radiobutton
Since the text "All" is the last node within the label, you can change only it by taking the amount of -1 nodes. For example, if the label has 3 nodes, you should take node 2 (as in an array, where…
-
0
votes2
answers54
viewsA: Why is the red background color not being applied in the menu?
This is because the selector #selected-menu has less priority than the selector #main-menu ul li a. The !important will cause the property given in the selector to override any other rule. In this…
-
5
votes1
answer257
viewsA: Javascript read txt file and interpret as code
The .innerText will insert the content as plain text, ie HTML codes will be treated as text. The .innerHTML will insert both text and render HTML codes if any. Just exchange node.innerText = text;…