Posts by Sam • 79,597 points
3,121 posts
-
2
votes1
answer82
viewsA: Send mailing list with jQuery
Really the ASP just goes release the return to AJAX when the while is completed. For this you should make a select in the database of only 1 email at a time: select email from tabela where enviado =…
-
2
votes1
answer192
viewsA: What does Event.target mean === Document.documentElement
It means whether the element that triggered the event click (event.target) was the very document (document.documentElement). That is, if you click anywhere empty on the page where there is no…
javascriptanswered Sam 79,597 -
1
votes1
answer68
viewsA: Loop of multiple IDS in jQuery
No need to use id’s on each form. Just take the form that triggered the event submit with this and $(this). Also because you are repeating id’s, as the #message. Change the #message by a class…
-
2
votes2
answers117
viewsA: Loop with columns and Rows
You can try this way, creating a new .row each time a counter reaches a multiple of 3 (see explanatory comments in the code): <?php $col = 1; // contador do laço $divrow = "<div…
-
4
votes1
answer244
viewsA: Detect the URL where iframe is being displayed
Use: top.window.document.location.href Will return the document URL more high, regardless of which iframe you call. For example: http://site.com/index.html | ----> iframe1.html (retorna…
-
1
votes1
answer35
viewsA: Jquery Mobile - scrolled button
The problem is that the indentation of <li> was as text space, and the snippet here is generating several (space), as shown in the print below: If you copy your code into a notepad…
-
1
votes1
answer271
viewsA: How to close a select by clicking outside it?
Click on document empty and hide the div.#my-options-container. Just check in the click in the document if the location of the click is not the div.my-select-container: $(document).on("click",…
-
0
votes1
answer144
viewsA: How to use ckeditor together with javascript
You can use the event keyup, for example, in this way: var editor = CKEDITOR.replace('editor1'); editor.on('pluginsLoaded', function(){ editor.on('contentDom', function(){ var editable =…
-
2
votes4
answers746
viewsA: Limit number of lines Textareafor
Maybe using the .readyState, the code will wait for the page to be fully loaded to apply the functions. Thus, you can use Regex /\n/g to count the number of lines and prevent more than 6:…
-
1
votes1
answer139
viewsA: Use comma input with Bootstrap Touchspin
If you want to exchange the point for the comma, you can replace the value input. Just use the events change touchspin.on.min touchspin.on.stopspin and replace one with the other:…
-
0
votes1
answer163
viewsA: Use 2 Onkeyup in the same Input
Create another function that will send the data to the other 4 functions. This function will also be in charge of validating the data, IE, do not need to call the functions that verify within the…
-
2
votes2
answers837
viewsA: Changing the class of a button with Javascript
You can do this by removing/adding only the class in question, without having to repeat all classes: As the friend said, the variable valor is already passed to the function, so do not need to…
javascriptanswered Sam 79,597 -
0
votes2
answers1908
viewsA: Typeerror: Cannot set Property 'innerHTML' of null
You are loading the script into <head>, with that the line: var log = document.getElementById("lognome"); Couldn’t find the element #lognome which has not yet been loaded, thus giving error in…
-
1
votes1
answer78
viewsA: Javascript Setinterval Does Not Work
Do not use setInterval() for this because there will be no sync with the time of .delay(), but the main problem (in addition to others) is that CSS only applies the background with :hover, and this…
-
3
votes1
answer151
viewsA: Image gallery with wide open image and side thumbnails
Place a specific class in the main div where the Thumbs images are (I put the class .thumbs: <div class="col-xl-3 thumbs" style="float:left;">) and another class in the main image (I put the…
-
2
votes1
answer616
viewsA: Textarea with lines of text size
Just adjust the textarea height by the scroll height it has: document.addEventListener("DOMContentLoaded", function(){ var txtarea = document.querySelector("textarea.form-control");…
-
0
votes3
answers41
viewsA: Check checked items and apply logic
As stated in the comments, repeating id’s is wrong and will always get the first element with id. Turn id’s into class and use document.querySelectorAll taking the elements by their respective…
-
3
votes4
answers58
viewsA: Repeat loop on id
You don’t even need to loop, just use the two selectors to pick the beginning of id’s, and then separate the alphabetical part of the numeric part and know which element to send the text to:…
javascriptanswered Sam 79,597 -
2
votes1
answer124
viewsA: Get URL from the page that called the file with jQuery . load()
Utilize $_SERVER["HTTP_REFERER"];. It will return the URL of the page that called AJAX, not the requested PHP page.
-
0
votes2
answers199
viewsA: Function load disables Jquery functions . Hide() and . show()
You have 2 problems with your code: Missing cancel the action of links with event.preventDefault(): $(document).on("click", ".BtnLogin", function (e) { e.preventDefault(); $("#cadastro").hide();…
-
0
votes1
answer69
viewsA: Recalculate when changing date or clicking the radio button
Create a separate function to calculate the total, do not do inside an event function because it complicates a lot. Note that I created the function somaTaxas() that goes through the last td’s of…
-
1
votes1
answer169
viewsA: Remove a Javascript function running with button click
Put an if in the function by checking the element with the class .img-magnifier-glass exists. If it exists, you remove, if not, apply the lens: function magnify(imgID, zoom) {…
javascriptanswered Sam 79,597 -
0
votes1
answer129
viewsA: How to disable Datatable jquery sorting when it is created manually?
You cannot change the options after initialized, except destroying the component and rebooting with new options. See: $(document).ready(function() { $('#datatable').DataTable(); // inicializa var…
-
0
votes2
answers343
viewsA: Select any div from a foreach
By the specifications, the attribute name is invalid in an element <p>. If your HTML structure is shown in the question, you don’t even need id nor name, even because you are repeating the…
-
0
votes2
answers422
viewsA: Calling event inside another jquery event
To call the event change in $(".c").on('change', function(e) {... you use the method .Trigger() jQuery: $(".c").trigger("change"); Now, how .c is a class, will trigger the event the number of times…
-
5
votes1
answer228
viewsA: Modal does not work (synchronous AJAX)
Nowhere in your code shows that AJAX is synchronous. AJAX, by its nature, was created to be asynchronous, how it represents its own name: AJAX (Tosynchronous JavaScript tond XML), that is to say,…
-
1
votes1
answer44
viewsA: Problem consuming API data and transferring a SRC to the ID
The return of fetch is stored in the variable json: .then(json => { ↑↑↑ So instead of response.data.name, should be json.name. However, since the return is an array of objects, so only json.name…
-
1
votes3
answers1207
viewsA: Pick selected radio button value and start IF, ELSE IF, ELSE
When using the Trigger .change() the event will scroll through all 3 radios, and this will not work properly because it will enter all if’s. What you need to do is just add the methods .parent()and…
-
2
votes1
answer70
viewsA: Mark Checklist container and run JS
You can do it this way, creating 2 functions: one that calculates the subtotals and one that calculates the total. Also create an Event Handler to trigger the functions when changing the checkbox…
-
2
votes1
answer600
viewsA: Month with two digits in getMonth, but giving error
You are concatenating the variable string mes with the number 1 in this section: var str_data = dia + '/' + (mes + 1) + '/' + ano4; Note that on this line the variable mes is a string: var mes =…
-
1
votes1
answer445
viewsQ: How to view the properties of an element in the console with pure Javascript?
With jQuery I can see the properties of an element on the console with: console.log($("elemento")); For example, if I have the element below: <input id="nome" type="text" placeholder="Digite…
javascriptasked Sam 79,597 -
0
votes2
answers126
viewsA: Is it wrong to create checkboxes with the same name?
With the same name only makes sense even use as array (adding [] at the name, as you are doing). Unlike radio, usually each checkbox has a name unique, but there is no problem in using this way. The…
-
0
votes1
answer138
viewsA: Add date-attribute in Columns using Datatable and Ajax
Add one more entry to the array return_data[] with the value cod_usuario: return_data.push({ 'razao_usu': json[i]['razao_usu'], 'cnpj_usu' : json[i]['cnpj_usu'], 'limite_usu' : limite_usu, 'aberto'…
-
1
votes1
answer473
viewsA: Make the input edge flash
With for you cannot do this. You could use a recursive function in this way: var temp1, temp2; if ($("#campo1").val() < 0){ let i = 0; function pisca(){ $('#campo2').css('border-color', 'red');…
-
1
votes2
answers765
viewsA: Datatable Data Format Problem
You can add the property columnDefs in the options, but first, remove the R$ of the columns. For example, instead of 'limite_usu' : 'R$ '+ json[i]['limite_usu'],, use 'limite_usu' :…
-
0
votes1
answer283
viewsA: Align text on top of button
Put the <p> (name of the author) and the <a> ("Read More" button) inside a div and place the class .mt-auto, and apply the properties display: flex; and flex-direction: column; in class…
-
0
votes5
answers217
views -
1
votes1
answer47
viewsA: Function on resize does not enable events
In your case, since you disable events with: $('.collapseMenu').parent('.menuItem').off('mouseenter mouseleave'); What you have to do is recall the code that enables the events. To avoid having to…
-
2
votes1
answer70
viewsA: Scope of variables in Event Attributes
Doing a little research, I realized that the attribute onclick is actually a function, that is, everything inside the attribute is inside a function onclick which is called at the click. When…
javascriptanswered Sam 79,597 -
-1
votes1
answer70
viewsQ: Scope of variables in Event Attributes
We know that when declaring a variable with var, it only loses the overall scope when declared within a function, for example: function f(){ var a = "string"; console.log(a); // string }…
javascriptasked Sam 79,597 -
2
votes3
answers4467
viewsA: How to make a scroll bar
If you want a scroll bar horizontal (and not vertical as you state at the end of your question), your code is right, only What you need to do for cards to always be the same width is to change the…
-
3
votes1
answer240
viewsA: Smooth animation of the lower div after removal of the upper div
You can use the .animate() of jQuery. After the .setTimeout(), take the negative difference of the position of the second div of the first relative to the top, then you animate the second div before…
-
1
votes3
answers598
viewsA: How to change the "src" attribute of a <script> tag using Javascript?
Just changing the src of the tag will not load the new script into memory or run it, ie it will not cause any effect. And even after loading the script teste1.js you will not be able to erase it…
-
1
votes1
answer79
viewsA: How to use the Slice method with negative values?
In this case, to return the first "s" of "saints", you would have to define the second argument with -5: var name = "maria mendonça maria maria dos santos"; console.log(name.slice(-6, -5)); And to…
javascriptanswered Sam 79,597 -
1
votes1
answer172
viewsA: Divs do not appear with display: block and rollover effect does not work
I think with CSS you won’t get this effect rollover because it would have to define a height fixed on the element, that is, if the element had a height fixed, would be possible only with CSS using…
-
0
votes1
answer35
viewsA: Script adding multiple submits to form in modal
By including the event submit within the event click you are creating multiple instances each time you open the modal. In this case you need to do 2 things: 1) Place events submit outside of events…
-
1
votes1
answer32
viewsA: Label não some Django
Your mistake is that you are placing the symbol # label selector, and this way the selector does not find the element: [for="#id_agencia"] ↑ When it should just be: [for="id_agencia"] You don’t have…
-
1
votes1
answer1282
viewsA: Take the data attribute value of an input file field
You can go through the type fields file and add to FormData() an array of values of data-name using .append(). Just assign the FormData() to a variable and use .each to add the values. An array will…
-
1
votes1
answer181
viewsA: Problem with Ckeditor used together with modal Bootstrap
This solution you are using only works in Bootstrap 3. In 4 you should put a _ before the property enforceFocus, and can leave the function empty. So change all this:…
-
2
votes1
answer819
viewsA: Fix div below Navbar - Bootstrap 4
Place content in a new div and apply BS4 classes: <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"> <!-- NAVBAR FIXA-->…