Posts by Sergio • 133,294 points
2,786 posts
-
6
votes4
answers20624
viewsA: Error: Uncaught Typeerror: Undefined is not a Function
To pass the jQuery as an alias for $ ( and so avoid conflicts) must do so: (function( $ ) { $(function() { // O seu código com dolar aqui }); })(jQuery); Apart from this detail it seems to me that…
-
6
votes3
answers8540
viewsA: Javascript floating point account realization with absolute precision
You can use the .toFixed() to create a string with the zeros you want: var numero = 11.8-10.2; console.log(numero); // 1.6000000000000014 (numero) var numeroTratado = numero.toFixed(2);…
-
4
votes3
answers228
viewsA: How to do repeating background with sprites?
The problem here is that you’re using an image that already has this zebra effect. To use background images in this way, which in the background are small strips that repeat horizontally, then the…
-
7
votes3
answers954
viewsA: How to list variables defined within a Javascript scope?
As @bfavareto also mentioned this is not possible in Javascript. However, if you plan your code well using a placeholder you can do this check. However, variables within functions are not accessible…
-
15
votes1
answer17504
viewsA: How to smooth the scroll of a page?
This page you mentioned uses a jQuery plugin called Nicescroll. It is very easy to implement, just need to put this code inside your tag <head>. #1 - load jQuery library <script…
-
8
votes2
answers1559
viewsA: Image distortion with CSS?
Yes, this is possible with CSS3. Bacco has already left an alternative, with a background image, here it is with CSS3: The idea is to create virtual elements with a shadow effect behind the image.…
-
5
votes5
answers17141
viewsA: Ignore CSS on a particular page snippet
Cannot remove/ignore closed CSS rules outside the element (ie in CSS sheet). If you have <input style="color: red;">, then it is possible to use jQuery $("selector").removeAttr("style"); to…
-
2
votes3
answers2326
viewsA: CSS Transition top
I suggest using the margin-top. In this case the CSS could be like this: .hand .card { position: absolute; transition: margin-top 0.3s; } .hand .card:hover, .hand .card.selected { margin-top: -2em;…
-
4
votes1
answer474
viewsA: Clear fullcalendar background
Your solution is correct. I add another that is preferable, by using classes instead of applying CSS directly to the element. // Remove todo background do calendário $('.fc-view-month > table…
-
4
votes1
answer465
viewsA: Enable input by clicking the button within the same row of a table
Find the hierarchical element that is common to the elements you are looking for. It is probably the <tr>. So you can use the .closest() to climb the DOM and find this "father", the <tr>…
-
2
votes3
answers543
viewsA: Make a rest screen with Jquery
You can do it like this: var ultimoMovimento = new Date(); var janela = $('#janela'); $(window).on('mousemove', function () { ultimoMovimento = new Date(); janela.hide(); }); var verificar =…
-
2
votes1
answer27528
viewsA: Calling Javascript function with onclick with content loaded from div
Your code has some errors. I do not know if it was in a hurry to put/simplify the example, or if you have errors in your code even. Once you’ve joined the jQuery tag here’s a hint taking all the…
-
1
votes1
answer314
viewsA: Wrong width in Chart div
Here is a suggestion: Show and hide options: $(document).ready(function(){ var $graficos = $('[id^=hg]').hide(); $('#selectsolicitacoes').change(function(){ var element = this.value; // tirei o…
-
1
votes1
answer529
viewsA: Modal window in event click
Since you have not put any code in your question, it is not possible to give an adjusted answer to your code that would be much more useful to you. So I answer more in theory and hope it helps you.…
-
3
votes2
answers297
viewsA: Script to pick tags with specific class and trigger onload
I believe that instead of injecting javascript into html it is better to tie Event handlers to the desired images... If you want to use pure javascript you can use it like this in two +/- similar…
javascriptanswered Sergio 133,294 -
2
votes2
answers402
viewsA: Alternative keyboard in input text
To prevent the button from being recorded if: the key is different from d or e the field does not have type=text You can use it like this: $('input, textarea').keydown(function (e) {…
-
2
votes2
answers403
viewsA: Pass list of objects between files
To access for example a function within an iframe in the same domain you can do so: var iFrame = $('#myIframe')[0].contentWindow; iFrame.receberDadosExternos('Olá!!'); This implies that there is a…
-
2
votes2
answers1579
viewsA: How to hide href with jQuery while input file is not selected?
Lauro, there are several options here, I always prefer to separate javascript and HTML to not have javascript inside HTML as in this case <a href="javascript:;…
-
15
votes3
answers24936
viewsA: Last position of an Array
You can use the end(). $ultimo = end($minhaArray); Another alternative is the array_pop() but this method also removes the last element, I do not know if it is what you need. If it is an associative…
-
10
votes3
answers6757
viewsA: How do I round up a value from 39.54 to 39
Assuming you have a string with the number inside you can use it like this: (I took several steps just to be clear) var string = '39,54 % OFF'; var novaString = string.split('%'); // aqui fica com…
javascriptanswered Sergio 133,294 -
4
votes1
answer1618
viewsA: Disable Space Key
In the jQuery the return false; has the memo effect that the event.preventDefault(); (and even makes .stopPropagation()). Your code as is should be enough to stop the event. In the code that shows…
-
4
votes1
answer819
viewsA: Perform action by pressing key
What you need to know is the position of the element you want to scroll to. This value can be found with the method .position() jquery: var posicao = $('#destino').position().top; To run the scroll…
-
4
votes2
answers1056
viewsA: I can’t remove the fields I just planted
I suggest simplifying your Javascript and avoiding having HTML inside Javascript. Since most of the code you want to insert already exists the same on the page you can copy instead of writing HTML…
-
2
votes1
answer3900
viewsA: How to make smooth bearing with button or anchor?
Here’s a hint, using jQuery/Animate: var frame = $('.texto'); $('.botoes a').on('click', function (e) { e.preventDefault(); fazerScroll($(this).parent().hasClass('up')); // chamar a funcao…
-
4
votes1
answer143
viewsA: Dynamically create controls
You have the $('#translados').html(str); inside for each, this will cause the content to be rewritten each time you loop it. You should use the .append() (adding to existing html), or using . html()…
-
14
votes2
answers2365
viewsQ: Simulate javascript keystroke events
I’m looking for a way to simulate keypress of shift + 1 via javascript to create an exclamation mark ! for a series of tests (specs) in a framework in which I am involved. I have used a framework…
-
1
votes1
answer2302
viewsA: Customize the appearance of the jquery-ui dialog widget
What you need to change is: .ui-dialog, the container of the dialog: Remove the overflow, ie: overflow: none; /* remover isto overflow: auto; overflow-y: scroll; */ .ui-dialog-content, the content…
-
1
votes2
answers1455
viewsA: How to find special characters that are inside other characters using javascript
If you want to change all "eu" it’s easy: var string = '{"text": "Olha "eu" aqui"}'; var stringLimpa = string.replace('"eu"', 'eu'); If you want to change all content of text then you can test this:…
-
5
votes3
answers497
viewsA: Take matrix size with EQ() - Jquery
If you want to know how many elements/objects this matrix has can use the .length that will give you the number of elements in the jQuery object. var matriz = $( "body" ).find( "div" ).length;…
-
7
votes1
answer263
viewsA: Make if condition with split
If the split finds one . then you want to measure the length of the idCliente, not the string size of the second element of the possible array. Try this way: idCliente.split('.').length > 1 That…
-
10
votes2
answers2006
viewsA: Problem with delay in jquery
The simplest seems to use the setTimout and the .Hide() (the .hide() does the same as .css('display', 'none')): setTimeout(function () { $("header").hide(); }, 1000); setTimeout(function () {…
-
1
votes1
answer700
viewsA: jQuery addClass in scroll
If I understand your problem well, each section should have its text in yellow when the scroll arrives, that is when that section is +/- in the middle of the screen. Here’s an example that works on…
-
1
votes2
answers397
viewsA: Increase an index to a certain number and then decrease until reset with jquery
Here’s another idea, using an object to store the value of the index and also direct it; because I didn’t see the question in time and without disrespect to the answer from Miguel Angelo that was…
-
1
votes1
answer218
viewsA: jQuery - how to measure the load time of an image in the background
I don’t think it’s possible to measure the load of a background. One idea you can test is to upload the image to a <img> that will never be used in the DOM. It will be used as a "test" to know…
-
5
votes5
answers6692
viewsA: How to make the textarea automatically increase height to a certain limit?
Here’s another idea: $('#texto').on('keyup onpaste', function () { var alturaScroll = this.scrollHeight; var alturaCaixa = $(this).height(); if (alturaScroll > (alturaCaixa + 10)) { if…
-
2
votes2
answers237
viewsA: How to add the fadein effect to this image transition code
You can use CSS to transition... Add transition: background-image 500ms; in your CSS file. It’s better to add to the CSS file than to add CSS rules via javascript. If in your case <body> that…
-
8
votes2
answers664
viewsA: How to effect "cascade" with Javascript / jQuery?
You can use it like this: $('ul li').each(function (i, el) { // percorrer cada elemento setTimeout(function () { $(el).addClass('on'); // adicionar a classe }, i * 200); // usar o indice do .each()…
-
3
votes1
answer1535
viewsA: Locate the next "less than" value in an array
Here is a suggestion: Sort the array using the Sort() optionally 1 to do numerical Sort search for the first number that is greater than or equal to $valor (alternatively one could look for the…
-
2
votes2
answers746
viewsA: How to generate a sequence of dates from start and end dates?
You can do it like this: var diaInicial = new Date($('#dataInicial').val()); // usar $('#ID').val() para ir buscar a data ao input var diaFinal = new Date($('#dataFinal').val()); var novaData =…
-
3
votes1
answer1779
viewsA: Calculate online time with Javascript/jQuery
Here is a suggestion: Use the event domready to record the milliseconds (timestamp) when the page loaded. Then use the event beforeunload to run code exactly before the page close. It is also…
-
2
votes2
answers121
viewsA: Adapt boxes to mobile layout
Without seeing your CSS I think the best option is to always have links. In desktop version prevents clicks in the mobile version: there are already. You can add this to the CSS (desktop) of these…
-
0
votes2
answers2165
viewsA: Jquery css if color text condition
The method .css() accepts an object to change several properties at the same time. The correct syntax is pairs 'propriedade': 'valor' Example: { 'propriedadeCSS_A': 'valor_A', 'propriedadeCSS_B':…
-
0
votes3
answers4136
viewsA: Update a table using javascript and arrays
Here’s a hint with jquery. I don’t know if you use pure javascript, jQuery, Mootools or another Javascript library... $('#adicionarFruta').on('click', function () { var $fruta = $('#frutas…
-
15
votes4
answers17179
viewsA: How to know if an element was clicked using pure Javascript
Similar to your selector with jQuery you can use the querySelectorAll and fetch all the elements that are descended from <li> and use a for loop for loops and tie an Event Handler to each.…
-
1
votes2
answers329
viewsA: Test results do not appear in browser - Grunt-karma
For Karma to close your browser you need to have Singlerun turned on. In the very description you have in the code: // Continuous Integration mode - Modo de integração continuo // if true, Karma…
-
2
votes4
answers37227
viewsA: Calling one function inside the other, through a string
Can use a namespace for this. A multi-function object calling the function it needs and does not pollute the global space as in its original idea. var validar = { date: function (value) { return…
-
12
votes9
answers37388
viewsA: What should I use in CSS, id, or class?
The choice to use ID's or Class(es) depends on what you need. The great difference, and that often leads to the choice of one of them, is: ID - One unique per page. Identifier: # CLASS - Multiple…
-
4
votes2
answers887
viewsA: Replace symbols < /> with Javascript
Tampering with HTML in this way is not recommended. But be a controlled test so: var conteudo= $('body').html(); // body ou o elemento que preferir // apanhar comentários conteudo =…
-
18
votes7
answers13788
viewsA: How to represent money in Javascript?
I found an interesting JSON here (and possible original here) that have useful information for formatting money. Missing 3 aspects that would be interesting to have: how to separate from 999, the…
-
9
votes2
answers42594
viewsA: How to open and close modals with jQuery
I don’t think it’s possible to do chain that way. I’m not 100% sure. Anyway you can do so: $('#myModal1').modal('show'); setTimeout(function () { $('#myModal1').modal('hide') }, 2000); Example…