Posts by Sam • 79,597 points
3,121 posts
-
4
votes1
answer63
viewsQ: What is the "groups" property in the result of a Regex?
When searching for a certain occurrence in a string with Regex without the flag g (of global), the result comes, in addition to the array with the occurrence found, other properties such as index,…
-
3
votes1
answer59
viewsA: Selecting direct checkbox from console
Besides what my friend Ghert said, that the right thing is getElementsByTagName, there is another point to note. As this function returns a nodelist (or an array with the elements that have the…
javascriptanswered Sam 79,597 -
2
votes1
answer113
viewsA: Reset, reset Hover behavior
You’d have to call the events :hover for a specific class and use events in Javascript to add the class to the elements that undergo animation. That’s because JS can’t change the state :hover of a…
-
1
votes1
answer32
viewsA: How to show in separate lines/inputs(os), the values of an array every time the Checkbox is clicked?
Use the first parameter of the .each to pass the array value disciplina. This first parameter represents the index of the element in the .each, but first empty the div with .empty() not to repeat…
-
2
votes1
answer235
viewsA: How to switch a CSS style sheet and maintain its state in Web Storage?
There is a way to do this by checking localStorage exists or does not exist. When you open the page, you check if it exists, that is, it has been created before. If it exists you enter a tag link…
-
0
votes1
answer22
viewsA: Autocomplete does not display php form data
This error is because you are searching for an element with id #dados_essenciais which does not exist. Instead there is an element with a class .dados_essenciais. Or you change the class for id in:…
-
0
votes1
answer569
viewsA: Go to next DIV
You do not need to use id’s and repeat multiple if’s to check which id was clicked, and show/hide a certain element by id. Imagine if you have 20 Divs, it would be a huge job in addition to the code…
-
4
votes1
answer174
viewsA: Is "use Strict" still useful with the new features brought in Ecmascript 6?
It is still useful because the Strict mode is not only related to variable declaration, as let and const, but also to other situations where Javascript Strict mode no exception is triggered,…
-
0
votes3
answers52
viewsA: Running the POST before onclick
When you click on the Submit button, you are calling a function with onclick and returning false case you enter any if within the function, thus cancelling the effect of Submit. Therefore, the…
-
1
votes2
answers88
viewsA: How to make the page title in blue?
This is not possible. The tag <title> is an element of metadata document, therefore it is not subject to visual styling, such as changing color, font size etc., nor even accepting tags, which…
-
1
votes1
answer102
viewsA: CSS cross-browser by Javascript
When moving the property style.transition is enough to work in all browsers? No. If a property needs a prefix in a given browser, you should put it in Javascript as well. The difference is that in…
-
6
votes2
answers194
viewsA: Remove text within a comment tag with PHP?
Why don’t you use one preg_replace? <? $string = 'a<!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1;…
-
0
votes2
answers109
viewsA: I wonder if there is any way in CSS to identify scroll scrolling
You can use Javascript for this (CSS only is not possible). You activate the function only when it exceeds 800 pixels scroll, and every time you move up the page the menu is shown (fixed) and as he…
-
0
votes1
answer174
viewsA: Range Slider Currency - Convert number to real value (Javascript)
Use .toLocaleString() to format the Real currency value and trigger the event input when loading the page to already show the formatted value: var range = document.getElementById("range"); var…
javascriptanswered Sam 79,597 -
0
votes2
answers51
viewsA: Start script after a preset time
Just send the h2 for the function typeWrite after the time you set in the variable segundos: function typeWrite (elemento) { const textoArray = elemento.innerHTML.split(''); elemento.innerHTML = '';…
-
1
votes1
answer37
viewsA: How to solve Struts Submit CSS?
Bootstrap 3 modal footer already aligns the elements on the right by default, due to native property text-align: right: That is, you do not need to apply styles to position the button, it is already…
-
2
votes3
answers351
viewsA: Invisible button after certain time
First you will hide the button with the property display: button.whats { display: none; } Then a Javascript to show the button after 10 minutes: <script>…
-
1
votes1
answer24
viewsA: Wrap Divs with the same class
With jQuery you can use .wrap(): $(".name").wrap("<label />"); Upshot:…
-
0
votes1
answer202
viewsA: Insert clickable link on a map with JSON
You can use the callback of the component after it is rendered: annualPopulation.render(function(){ // callback }); Inside the callback you will traverse all the path creating a onclick for each…
-
1
votes2
answers373
viewsA: How do I redirect my form to another page?
Use preventDefault() to cancel the button action and change the attribute action of the form with the option value before submitting it manually: $(function() { $('#btnget').click(function(e) {…
-
1
votes1
answer57
viewsA: Grab image data-src open in lightGallery
Actually you don’t need to take the data-src, because the value of this attribute is the path of the image that will be displayed in the slider, so just take the src of the current image being…
-
7
votes4
answers205
viewsA: Catch event that happened on page
You can iterate on the object properties document and create a Event Listener only in properties that begin with "on", such as onclick, onBlur, onmouseover etc. which are the properties of events.…
-
2
votes3
answers96
viewsA: Generate HTML using Javascript
First of all, you need to convert the form elements' numbers into an array, otherwise you won’t be able to get them in the backend when submitting the form. You must put the clasps [] at the end of…
-
3
votes1
answer1035
viewsA: Select Multiple with jQuery Chosen
Before calling the .chosen(), place the attribute selected in all select options: $("#SistemasComerciais") .find("option") .prop("selected", true) .end() .chosen(); <script…
-
0
votes1
answer1305
viewsA: Round edges table CSS3
Table edges do not accept border-radius, but the background accepts. So, you can round the bottom edges of the table, as tds have a background color. Just put the properties that change the edge of…
-
1
votes3
answers571
viewsA: position: Sticky; does not work
Sticky will not work in the element thead (nor in the tr) in the Chrome. You will have to use at all td'are in the thead: html, body { height: 100em; } thead td{ position: sticky; position:…
-
7
votes4
answers349
viewsQ: How to make an element cross the screen continuously and always visible?
I have a CSS animation of an element that crosses the entire screen, from right to left, continuously infinitely: #slider{ position: absolute; top: 50px; right: 0; background: red; width: 150px;…
-
0
votes1
answer110
viewsA: Insert cloned items into the form with PHP and Mysql
The only way I see it is by creating indexes and sub-indices in complement arrays. For example, in the first category form, add-ons would be in sequence: Complemento 1: name="ds_complemento[0][0]"…
-
1
votes2
answers478
viewsA: Styles of my Datatable does not load in modal
You need to start the component with the command: <script> $("#bootgrid-command").bootgrid(); </script> See the documentation…
-
0
votes1
answer50
viewsA: Queue to View Modal Bootstrap
Create an array that queues incoming messages and use a recursive function that displays each item of the array until they run out, sequentially defined by setTimeout’s. The variable ativo will…
-
1
votes2
answers264
viewsA: Redirect to a URL if Javascript is disabled
Following the suggestion of the hugocsl, I decided to insert a <noscript> also in the head with the meta tag. According to this specification HTML5.2, it is allowed to insert tag…
-
4
votes2
answers264
viewsQ: Redirect to a URL if Javascript is disabled
Using the tag <noscript> it is possible to detect when the Javascript engine is disabled in the browser (as per this question), but how to redirect the browser, after a few seconds, to a…
-
1
votes2
answers37
viewsA: Change a class that is inside an id with Javascript
There are many ways to do this. In addition to the shape shown by Victor Carnival, you can also use the querySelector(), which accepts CSS selectors and is much simpler and more flexible:…
-
2
votes1
answer59
viewsA: How do I stop the image from disturbing the input?
Insert the style into your CSS: .imgcontainer + div{ position: relative; z-index: 1; } This will make the first div after .imgcontainer stay on top of .imgcontainer. The sign + means adjacent…
-
3
votes1
answer1088
viewsA: Error using Javascript removeChild function
It is occurring that at the time of using the removeChild, the element created is not yet a child of div#DivPrincipal, that is, it was only created, but not yet placed in the div. For example, when…
javascriptanswered Sam 79,597 -
0
votes2
answers66
views -
0
votes1
answer36
viewsA: responsive image - showing a pixel line when you hover your mouse
The images with the edges are exceeding 2 pixels in the width of the div.opacidade, making sure that, in the transparency effect, the black background of the container does not "cover" the whole…
-
2
votes2
answers84
viewsA: How to make all checkboxes unchecked and the value empty inside if?
You can do unknowing all checkbox with: $("input:checkbox") // seleciona todos os checkbox .prop("checked", false) // desmarca todos .val(''); // esvazia o value de todos Since you are using jQuery,…
javascriptanswered Sam 79,597 -
1
votes2
answers41
viewsA: Reading fields from a table
As colleague Rafael said, take the properties of the object using get_object_vars, then you concatenate the $x of the loop with the name of the fields: while ($row = mysqli_fetch_object($query)) {…
-
0
votes2
answers45
views -
2
votes1
answer228
viewsA: Error: Syntax error, unrecognized Expression with "string"
You do not need to construct the selector with quotation marks. The variable inside $() already passes its own value as a reference. For example, the variable string firsts only need the selector…
-
1
votes1
answer38
viewsA: How to pass this Jquery code in pure Javascript
Can use document.addEventListener checking with event.target which element was clicked (click) or modified (change) (the event is the first argument of callback, where I can give any name. In case I…
javascriptanswered Sam 79,597 -
1
votes2
answers249
viewsA: How to view JSON data in jQuery Datatables via Ajax?
Table structure is wrong. According to documentation, the table structure should be basically: <table id="id_da_tabela"> <thead> <tr> <th>texto</th> </tr>…
-
-1
votes1
answer402
viewsA: Does splice remove an object from the array?
In addition to removing, the .splice() will create another array with the object, in your case, the one found in if. Soon, coleta would be an array like: coleta = [0]: {"nome": "lata de ref.",…
-
3
votes1
answer42
viewsA: Zebra table in gray and white
Your error is in the semicolon ; that you are joining to hexadecimal: html += "<tr bgcolor = " + list[i][5] + ";>" + ↑ Is resulting in invalid value, this way: bgcolor="#4F4F4F;" ↑ When the…
-
0
votes1
answer45
viewsA: If the select option is selected, then another option is added?
If I understood the purpose correctly, you could put a value in the select options of cities with indexes (index): cidades.forEach(function(item, index){ $('#cidades').append('<option value="'+…
-
2
votes1
answer36
viewsA: Change buttons to appear as quantities are dropped
Whereas the instalments paid are in sequence from the first to the last, just change your ternary checking whether the variable $p of the loop for is greater than the value in…
-
2
votes1
answer169
viewsA: How to UPDATE with AJAX + PHP + PDO
You are repeating several id’s, which is incorrect in HTML. An id serves to identify an element on the page individually, just as the CPF differentiates a citizen from another. What you can do is…
-
2
votes1
answer316
viewsA: Table row with link
The attribute href is only applicable to some tags (a, area, base, link), therefore has no effect on tag tr. You can do it with pure HTML? What you can do is use the attribute onclick and redirect…
-
6
votes4
answers317
viewsA: Regex to identify all occurrences of years
Use: .*(20[1-2][0-9]) Group 1 will always be the last sequence 20XX (where XX is in accordance with the regex criteria): 3420201298 -> grupo 1: 2012 ¯¯¯¯ 34352020982012 -> grupo 1: 2012 ¯¯¯¯…