Posts by Sam • 79,597 points
3,121 posts
-
2
votes1
answer135
viewsA: Exchange standard POST form
Place an Hidden input in the form and send the object to it before the normal Submit via the action post, and not via Ajax. So you can receive this input in the backend and treat the object as you…
-
0
votes2
answers310
viewsA: Is it possible to check if an element does not have the style attribute with jquery?
Complementing the reply of @Sergio, you can check the last tr table with the selector :last jQuery: if($("table tr:last").is(":hidden")){ // não está visível } If you only have 1 table on the page,…
-
0
votes2
answers526
viewsA: modal call does not work (bootstrap)
You don’t need to call a function to open the modal. Just put in the tag <a> the attributes: data-toggle="modal" data-target="#modalSenha" In the data-target you put the modal id. Only this…
-
2
votes1
answer39
viewsA: I have a Javascript error and I can’t fix it
The return of Ajax is not an array, it is a list of objects listed within the object potions, and not data: { "potions": { "1": { "id": 1, "name": "Aging Potion", "image": "aging-potion.png",…
-
3
votes1
answer619
viewsA: View content only after full page load
Use Ajax to load div content #content. Because it is asynchronous, the Oader will be visible until the content is loaded into the div. Do the following: Hide the div #content in your CSS: #content{…
-
1
votes1
answer96
viewsA: Subtraction in rows of a table using Datatables
Remove all repeated id’s. You cannot repeat the same id on more than one element on the page. Send the this for the function calcularvalor in the onfocus: onfocus="calcularvalor(this);" The this…
-
1
votes1
answer46
viewsA: Initialize variable
You are applying styles (attribute style) to the element <p> with the id #result. To get back to normal you can do it in two ways: 1) Empty the attribute style:…
-
0
votes2
answers41
viewsA: Uncaught Referenceerror: hr_tb is not defined
The variable hr_tb only has scope within the function of $(document).ready. By the way, it makes no sense to put the event .ready within a function, as this event is triggered when the DOM is…
-
0
votes1
answer79
viewsA: How to assign a script to a button?
You are duplicating the function myFunction(). So the second will overwrite the first, and will only work with button 2. You should use only one function and pass the onclick the parameter this,…
-
1
votes1
answer50
viewsA: Jquery - Problems with checkbox editing function
When using .on() inside .on() will create and accumulate the .on() nestled each time the .on() is triggered, i.e., by clicking .edit the first time will create the two events .on() nested. In the…
-
1
votes1
answer1164
viewsQ: What is the appropriate use of display: table?
As its name says, the display table makes the element (Divs, sections, etc.) have a very similar behavior to a table with the tag <table>, where we can use child elements with the property…
-
1
votes2
answers84
viewsA: Why doesn’t my if return true?
On the line: var img = window.document.getElementsByTagName("img")[0].src; Returns the absolute path of the image. And inside the if you’re picking up again .src: ↓↓↓↓ if (img.src ==…
javascriptanswered Sam 79,597 -
5
votes2
answers2472
viewsA: Fetch words between quotation marks through regular expression
It is because your regex is not finding anything in the string. There is no occurrence in the string between a pair of double quotes. The names you want are between two quotes only. But also you…
-
3
votes2
answers429
viewsA: How to filter object
The x in your filter returns each object of the listalunos, then there’s no way of knowing if the note inside the object is greater than or equal to 7 just with x >= 7. You have to access the key…
javascriptanswered Sam 79,597 -
0
votes1
answer201
viewsA: Multiple select saves everything in the bank, how to save only what I chose in select?
Just make a implode in the array using the comma as the value separator: $diaensaio = implode(",", $_POST['diaensaio']); Suppose we selected the days MONDAY, FOURTH and FIFTH, with the implode the…
-
2
votes4
answers196
viewsA: How to mark and uncheck div (by checking and unchecking Checkbox) with jQuery
Dude, I would suggest that you put both the icon and the text inside the label, because then when you clicked on either of the two would already mark or deselect the checkbox for. This is because,…
-
1
votes3
answers484
viewsA: Display only the first 3 elements of a list (Javascript, jQuery)
Use the method .Slice() jQuery with value 3. Since the value is base 0, it will hide from 4th element (index 3) to last: $(".minhaClasse li").slice(3).hide(); <script…
-
1
votes1
answer65
viewsA: Change the value of a Slider in each table row
The first problem is that you are repeating the id #myRange. Only then will problem in the event selector click. An id should be unique on the page. When you will use several similar elements, you…
-
1
votes1
answer131
viewsA: Run script only once
Attribute the setInterval is a variable and cancel it in the callback of the .load(): $(document).ready(function(e) { $.ajaxSetup({ cache:true }); var timer = setInterval(function() {…
-
1
votes1
answer2478
viewsA: Slick Slider Autoplay
You are probably starting the plugin before loading the slider’s HTML. With this the plugin does not find the div .single-item and all the slider images are displayed on the screen. You need to…
-
1
votes1
answer32
viewsA: Check if the span of the same column has the same class with pure Javascript
One way I found it is with the help of an array, where you will store the column index inside the Row where an element with the class was found .numeroSorteado. As there are 3 columns, if found in…
javascriptanswered Sam 79,597 -
2
votes1
answer35
viewsA: Why is my cancelAnimationFrame() not working in Javascript?
Put a return; after calling objeto.stop(); within the anima(), otherwise the code will continue on the next line id = requestAnimationFrame(objeto.anima); that continues the animation: window.onload…
javascriptanswered Sam 79,597 -
1
votes1
answer66
viewsA: Custom image in Javascript or jQuery
The image gets flattened because you set fixed square size. If the user loads a horizontal or vertical photo, it will lose proportions and flatten, because it will force the image to be 150x150…
-
2
votes1
answer60
viewsA: Change content of ::after
Pseudo-elements are not accessible via Javascript (see the duplicate). What you can do to change them is by adding a class that changes the ::after in CSS. Now there are problems in your Javascript,…
-
3
votes2
answers474
viewsA: Two actions on the same button
Can change the href from the link after the first click, all within the attribute onclick: <a id="botao2" href="http://primeirolink.com" target="_blank" onclick="var t=this;…
-
0
votes1
answer30
viewsA: How to apply border-shadow on a parent and child element with Hover?
Just add a new rule to .plan--highlighted:hover adding the child element class that you want to apply the same property: .plan--highlighted:hover, .plan--highlighted:hover .plan__annotation { /*…
-
0
votes1
answer49
viewsA: Check if tags have the same class with pure Javascript
Makes a for running through each .row counting how many elements have the class .numeroSorteado within it .row. If the value is equal to 3, BINGO! Behold: var sorteio =…
javascriptanswered Sam 79,597 -
3
votes2
answers76
viewsA: Reserve image - SRC
You can check in PHP itself if the image file exists: <img src="assets/images/<?=file_exists("$username.png") ? "$username.png" : "avatar-1.jpg" ?>" alt="" class="user-avatar-md…
-
1
votes1
answer807
viewsA: How to change elements dynamically through Checkbox?
You are cloning a div that has some elements with id’s. An id cannot be repeated on the same page. For example, in the case of the checkbox label where the attribute for reference to the checkbox…
-
0
votes1
answer61
viewsA: Slide with mother div background image exchange
Swap out the callback onSlideNext for onSlideAfter and seek the src of the image in the div that contains the attribute aria-hidden="false". It will replace the div background with the image being…
-
2
votes1
answer140
viewsA: Identify inputs in a div
You can pick it up by tag name using .getElementsByTagName() the index of the elements, starting with the 0. But first you have to catch the father div with .parentNode. To do this, just send to the…
-
2
votes1
answer68
viewsA: How to use localStorage in this case?
Instead of using the attribute onclick on each of the buttons, create a Event Handler onclick in all of them and put in each one a dataset with the name of the color. For example: data-cor="blue"…
-
0
votes1
answer122
viewsA: How to copy the contents of one <td> to another <td> in another table row?
If you want to copy the information to the new line in the classes .descricao and .quantidade, just enter the code below before the return false; of function AddTableRow: // pega o texto da 2ª…
-
2
votes2
answers620
viewsA: localStorage save some fields
You do not need to create a Torage locale for each field. Just create an array of objects where each object in the array will have keys with the information, something like: [ {"rua": "rua 1",…
-
3
votes4
answers99
viewsA: Simplify value localization in arrays in PHP
Can use array_search (array search) and array_column (search for a specific column): foreach ($codes as $i) { echo "<p> {$records[array_search($i, array_column($records, 'id'))]['name']}…
-
2
votes3
answers196
viewsA: Fill in a text field with information from another field by clicking on a radio button
A simple form with jQuery, which only checks the radiobutton and adds the name in the other field if the first field has any thing typed: $("[name=Coordenador]").on("click", function(){ var nu =…
-
4
votes3
answers964
viewsA: Calculate change and display available notes with Javascript
Create your own function to calculate notes and use an array of values in descending order: var notas = [50,10,5,1]; Send the change value to the function and loop the array by deducting the change…
-
4
votes2
answers90
viewsA: Changing title of div
Don’t use the event hover. It has been removed from jQuery since version 1.9, and even if you are using a compatible version (up to 1.8), use mouseover (or mouseenter):…
-
9
votes1
answer190
viewsA: How do I pause a script when I leave the page?
The setTimeout cannot be paused, or you cancel or start it. In this case you can cancel the 4 setTimeout’s using the event window.blur and recall functions in the event window.focus. For this we…
-
7
votes2
answers42
viewsA: In this case am I or am I not required to declare the same variables?
You don’t need a second function. Just call the function clock() using setTimeout instead of setInterval. Why setTimeout? Because the setTimeout only rotates once. If used setInterval, that runs…
javascriptanswered Sam 79,597 -
1
votes1
answer113
viewsA: Hide Javascript menu
The .navLinks (menu) should already come hidden. Add display: none in class: .navLinks{ float: right; display: none; } Then just create another breakpoint with min-width: 992px before what already…
-
2
votes5
answers585
viewsA: Footer content does not cover the entire screen
The class .container on the footer will cause it to not have the full width of the screen. This class has breakpoints which varies in width according to screen resolution. If you want the footer to…
-
0
votes1
answer49
viewsA: Class change problem in jQuery
It’s because you’re changing all the <i> of all menu items. You would have to change only those that contain a <ul>. I also put in CSS the style below so that ul’s start closed: .menu…
-
0
votes1
answer910
viewsA: Javascript to open a Bootstrap modal
One thing wrong with your HTML is that you cannot put Divs inside the tag <p> how are you doing. Regarding a generic function, you can place each block of HTML referring to modals within a…
-
2
votes3
answers291
viewsA: Javascript character limit to full stop
Just check if the string contains more than 130 characters with .length(). If so, you take the characters from the 1st to 130th with .substr(0,130) and concatenates with "...". Example: var dado = {…
-
1
votes2
answers69
viewsA: How to interact multiple dropdown menu?
There is a more generic way to do this without having to create a function for each button and use id’s. Just put a class in the buttons to add Events handlers to all. Clicking on the button will…
-
0
votes2
answers687
viewsA: Card clickable with Bootstrap 4
Just change the card tag to <a> and place an attribute href with the URL to where you want it to go when clicked. Now, you don’t need those styles you put in the class .loginUser which, with…
twitter-bootstrapanswered Sam 79,597 -
4
votes2
answers2685
viewsA: How to delete HTML elements using Javascript?
First you are creating elements with equal id’s, which is already wrong. An id should be unique on the page. Another problem is that you are using click() as a function, which cannot because the…
-
2
votes2
answers638
viewsA: jQuery Mask does not work on elements created dynamically
Use the form below to apply the plugin automatically when the field gains focus, including fields cloned or dynamically added: $(document).on("focus", ".money_format", function() {…
-
1
votes1
answer51
viewsA: Allow editing of input
Create another Event Handler with the event input only to the countryside #formaTaxas. Changing the field value will also change the attribute value data-taxa active option in select:…