Posts by Sam • 79,597 points
3,121 posts
-
2
votes1
answer40
viewsA: If you return data from the database Else is invalid
It is because Datatables, when there is no data coming from Ajax, automatically creates a line with only one column informing that there is no data to show, and when entering the if will try to pull…
javascriptanswered Sam 79,597 -
2
votes2
answers233
viewsA: What are the ways to use Return in Javascript and how do they work?
The statement return finalizes the execution of a function and specifies the values that must be returned to where the function was called. (MDN documentation) By omitting in the return the variable…
javascriptanswered Sam 79,597 -
2
votes2
answers71
viewsA: Swap the image with one click on multiple records
Just use a Event Handler onclick (no need to use an event attribute onclick in each image). Then, remove all onclick="test()" of the images and use: document.addEventListener("DOMContentLoaded",…
-
1
votes2
answers48
viewsA: Problems in consulting with NOT IN
The function mysqli_fetch_assoc() pulls each line found in the query each time it is called, i.e.: -> mysqli_fetch_assoc($queryEmail) // retorna o primeiro registro ->…
-
2
votes1
answer713
viewsA: Positioning images using Flexbox
To center the image you should use the flex in the div where the image is, not the image itself, and use the property justify-content: center; to center vertically within the grid: .container {…
-
1
votes1
answer17
viewsA: jQuery does not find td generated by Ajax
It turns out that the $(this) function does not reference the element clicked because it is not a function of the event fired onclick. What you should do is send the element clicked through a…
-
1
votes2
answers105
viewsA: How do I treat a jQuery array (remove duplicates and prevent an item from appearing in 2 arrays)?
Do not use id for the elements, because you will be duplicating id’s on both buttons, which is wrong in HTML. Instead use dataset data-id, for example: <button class="btnlike"…
-
3
votes2
answers66
viewsA: Prevent user to change field before completing
I see some problems in your code. First the name of the function called in onblur is different from the function name: @onblur = "return ValidaHora(this)" <-- "V" maiúsculo ↑ function…
-
1
votes1
answer710
views -
4
votes5
answers964
viewsA: How to progress steps using thread chart?
One suggestion is to create progress bars with Javascript and show the bars according to progress, proportional to the maximum steps, no use of libraries or jQuery, with pure Javascript. The code…
-
2
votes1
answer73
viewsA: Add next date whenever I create a new line
Create a function that will return the date in the format dd-mm-aaaa: function novaData(d){ var dia = d.getDate().toString(); dia = (dia.length == 1) ? '0'+dia : dia; var mes =…
javascriptanswered Sam 79,597 -
2
votes1
answer110
viewsA: How do I make a dynamic pagination run the same function it was rendered?
Create a Event Handler for links that are not within the <li> with class .active, firing a Trigger for the event .submit form, passing a parameter with the button number: $(".pagination…
-
6
votes2
answers441
viewsA: Show and hide button with jQuery
It is because after try to show off the button #submeter inside the button click event #IniciarTarefa, you are calling the function setDisabled() which again hides the button. So just condition the…
-
1
votes1
answer47
viewsA: Linear-gradient with an image
Change the value 70% of linear-gradient by a function calc(100% - 170px), discounting 170px the width of the div. These 170px represent the part of the image width you want visible plus the paddings…
-
0
votes4
answers1595
viewsA: Leaving div height equal to width using css only
Unused flexbox, you can use float: left in the Ivs and overflow: auto in the container, using the technique of Aspect ratio 1:1 with padding-top of the same value as width, that is to say, 25%:…
-
0
votes2
answers43
viewsA: How do I show a select according to the previous option?
Just check that the value of select is "global" and hide the elements. If it is another value that is not "global", it shows the elements. And you don’t have to use the .hide() twice, just use once…
-
0
votes1
answer24
viewsA: Mouseover/out only on one menu item within several caught by jQuery selector
jQuery has its own method of calling two events at the same time, the .Hover: $(elemento).hover( function(){ // função do mouseenter (quando passa o mouse) }, function(){ // função do mouseleave…
-
2
votes2
answers171
viewsA: I can’t get content (number) of some tags read
There is the querySelectorAll. The advantage of this to the getElementsByClassName is that it accepts CSS selectors, making the selection of elements more flexible. Like the getElementsByClassName…
-
0
votes1
answer39
viewsA: Input field filling
Can apply a onblur in the field calling the function: formulario.valor_ufm.onblur = calcularUFM; Or directly in the element: <input type="text" name="valor_ufm" onblur="calcularUFM()" />…
-
0
votes1
answer81
viewsA: Function in Jquery stopped working after inserting Datatable into page
This error is happening when you use Datatables because it adds classes odd and even (Stripe classes) lines classes, and this is causing error when you take these classes to use as jQuery selector.…
-
2
votes1
answer61
viewsA: Autocomplete does not go to the specified page
You can submit the form using the event select (see documentation). In the event function search the form using .closest("form") and submit with .submit(): $("#autocomplete").autocomplete({ source:…
-
0
votes3
answers470
viewsA: Real value (R$) for Javascript number
With replace using regex you eliminate anything other than a number and a comma, and replace the comma by a dot: -> n = R$ 123.456.789.123,11 -> n.replace(/[^\d,]/g, '') -> 123456789123,11…
-
1
votes2
answers89
viewsA: Move body along side menu
With jQuery, use the events mouseenter and mouseleave to change the body’s left margin (margin-left) using .animate() when the mouse passes over to div#lateral. Since you’re using a 500-pixel…
-
1
votes3
answers67
viewsA: Regex is not working with file_get_contents
The archive .chr has a type of encoding that adds "spaces" between characters when read by file_get_contents(). See how it is returned in the browser: But these spaces are not common spaces, they…
-
1
votes1
answer139
viewsA: Fullcalendar in Bootstrap Modal
Use !important to force the property declaration (see this topic): .fc-ltr .fc-basic-view .fc-day-top .fc-day-number { float: right; color: #000 !important; } .fc-unthemed thead,.fc-day-header,…
-
0
votes4
answers59
viewsA: Div in the center next to each other
Besides the lack of Divs closure, it is not recommended to use <br> for spacing between elements. The tag <br> should be used only for line breaking between type elements phrasing…
-
1
votes2
answers49
viewsA: "Filter" is not closed
Do as follows by calling the function LoadJsonData sending as callback parameter the function showPeople. The value of the variable jsondata will be sent by Ajax callback to the function showPeople…
-
2
votes2
answers541
viewsA: Bold words from my HTML using Regex
Capitalized works because JS is case sensitive, that is, after it changes the first occurrence, it is no longer found by replace and every loop in the loop for will fetch again the first occurrence…
-
1
votes1
answer1845
viewsA: Show image when mouse over a div - CSS
In fact you want the image that is inside each li appears in a div off menu while hovering the mouse. With this HTML structure, only with CSS you won’t be able to do this. You have to create a div…
-
1
votes2
answers689
viewsA: Disable link with jquery
You’re probably wearing one Event Handler to listen to clicks on links. If you are using a version 1.7 or higher, use the method .off() to remove click events from elements: $('.btnRemove, .btnShow,…
-
2
votes2
answers132
viewsA: What is the correct linear-gradient (CSS) syntax in Javascript?
The mistakes are: Instead of linearGradient, would be linear-gradient. The camelCase is only in the Javascript property, the value has the same syntax used in CSS. Cannot contain the semicolon at…
javascriptanswered Sam 79,597 -
2
votes2
answers51
viewsA: Why doesn’t Event exist inside the lower block?
The event is a global variable window and only gains properties within the Event Handler, like the addEventListener. The setTimeout is a global function that does not assign to the variable event…
-
0
votes2
answers38
viewsA: Setting menu abruptly
Use a .fadeIn() to smooth the appearance of the menu when it fix. In relation to "harm the scroll", as only by the code shown can not reproduce the actual functioning of the page, it may be that…
-
2
votes1
answer35
viewsA: Hide selection screen in Cropper.js
You need to hide the div where the element is <img id="crop"/>. For this change the following line in the function of the $('.salvar').click: document.getElementById("crop").style.display =…
javascriptanswered Sam 79,597 -
4
votes2
answers37
viewsA: Doubt as to whether to exclude specific elements of the clone() function
If you want to remove all <b> and the <br>, you can do it in two ways: Using .remove() Convert the variable clone, which is a string with the HTML of div, in HTML object with…
-
1
votes2
answers78
viewsA: Limit text to be selected from input with Javascript
Using the regex below with .match() you can get the code: \+\d{1,3} The pattern will capture the + followed by 1 to 3 numbers. Example: $("input").on("focus", function(){ var ddi =…
javascriptanswered Sam 79,597 -
1
votes2
answers161
viewsA: Vertical paragraphs using flexbox
Places the property flex-direction: column in the div class that owns the property display: flex (in the case, .vertical-align) that it will behave as a column, and the elements will be below each…
-
0
votes1
answer161
viewsA: I would like to know how to style the titles of the site, to have a dash on each side
You can use flexbox to do this by creating two pseudo-elements, ::before and ::after, to construct the lines (see explanatory comments in the code): body{ margin: 0; background: #000; font-size:…
-
13
votes2
answers1560
viewsQ: What is the difference between window.Location and window.location.href?
I’ve always used window.location.href to redirect to another internal page or external URL, but when using only window.location (without the .href) produces the same result, i.e., makes the same…
-
0
votes3
answers388
views -
1
votes2
answers94
viewsA: Input text value does not change when triggered by the button
The way you’re doing it is very bad. Instead of repeating the script and creating id-based functions from the PHP loop, you can create only a single function both to increment the value in the input…
-
1
votes1
answer313
viewsA: Getting the Datatable Server-side ID
For dynamic elements, use render instead of defaultContent: render: function(data){ return '<a href="editar?id='+data[0]+'" class="editor_edit button blue">Editar</a> <a…
-
0
votes3
answers388
views -
3
votes1
answer109
viewsA: How to call a PHP function that returns a string using jQuery or Javascript?
You can use the method .load() jQuery: $(seletor).load(url); Where: Selector: element to which the result of the request will be sent. url: page to be requested. In your case I’d be:…
-
1
votes1
answer44
viewsA: Menu changing as per resolution
Place display: flex; in .nav to use it as flexbox and add the properties flex-grow: 1; and text-align: center; in .nav li to distribute the li within the full width of the menu and center the text.…
-
4
votes2
answers60
viewsA: How to hide a table row that the information contains *
Just go through all the td's and remove the line from td with only the asterisk: document.addEventListener("DOMContentLoaded", function(){ // seleciona todas as td's da tabela var tab =…
-
2
votes1
answer53
viewsA: When inserted content into the div, the page does not scroll right
You don’t need to take the height of window to do this. Just put it in the CSS, in the class .secao, the property height: 100vh; so that Divs always have window height. .secao{ position:relative;…
-
1
votes2
answers52
viewsA: How to format the mm/yy field in Javascript?
With pure Javascript you can format the field by adding a bar when the number of characters is equal to 2. Just you pick up the fields by the common class .monthPicker and apply a onkeydown in each…
javascriptanswered Sam 79,597 -
2
votes2
answers76
viewsA: Insert a background inside a triangle in the corner of a div
You can use the property clip-path to display only a part of the ::after. In the example below I cut out the ::after of the element in the form of a triangle with 3 coordinates. The coordinates are…
-
3
votes1
answer273
views