Posts by Sergio • 133,294 points
2,786 posts
-
1
votes2
answers730
viewsA: Multiply select by radiobutton
Vinicius, here’s a suggestion: window.onload = function () { var inputs = document.querySelectorAll("[name=diarias], select"); for (var i = 0; i < inputs.length; i++) {…
javascriptanswered Sergio 133,294 -
1
votes1
answer46
viewsA: Problem in effect acordion simple in paragraphs
Yes it is possible. I would do so: $(document).ready(function () { $(".titulo").hover(function () { $(this).next().toggleClass("outros"); }, function () { $(this).next().toggleClass("outros"); });…
-
7
votes1
answer119
viewsA: How to add a class to a div when it is active, so it changes color?
I was very close, I made a change and added a line to remove classes that had been added to other elements Forehead like this: $('.panel-heading').on('click', function () { var self = this;…
-
2
votes1
answer487
viewsA: How to make div s colapsáveis open without the buttons of the other div s descend?
Here is a suggestion: var bigMedia = $(window).width() < 750 ? false : true; // detectar se o ecrã é grande ou pequeno $(window).resize(function () { bigMedia = $(window).width() < 750 ? false…
-
1
votes1
answer275
viewsA: Problem with Post ajax and Javascript Object
This is not exactly a solution, it’s more of a finding. According to jQuery’s documentation, when using objects in data they must be simple objects: date Type: Plainobject or String Data to be sent…
javascriptanswered Sergio 133,294 -
7
votes6
answers5717
viewsA: Disable Chrome Password Save in Javascript
Reading the answer from Markus Olsson in Soen, the suggestion is to use the autocomplete HTML to tell browser not to save information: <form id="loginForm" action="login.cgi" method="post"…
-
6
votes2
answers6999
viewsA: How to change content of a select from another select
Your question is incomplete. I can help more to explain what it takes in a question, or next questions, to be clear to those who want to help. At the Meta there’s definitely a question reference but…
-
1
votes3
answers192
viewsA: How to write an array post in current Intel - input file
Test like this: $file= $_FILES['file1']; // trate este valor como uma array foreach( $file as $esteFile ) { if( $esteFile != '') { // UPDATE } }
-
1
votes1
answer1892
viewsA: Automatically select a select and press the button
Test use so to know if a select has only one option: $('select').each(function () { var options = $(this).find('option'); var qtdOptions = options.length; if (qtdOptions == 2) { // uso dois porque a…
-
2
votes2
answers5750
viewsA: How to catch a json on an external server with Javascript?
What you need is to make an AJAX call... Example var endereco = 'http://echo.jsontest.com/key/value/one/two'; $.ajax({ url: endereco, complete: function(res){ var meuJSON =…
-
3
votes3
answers5402
viewsA: Fade effect on image exchange with jQuery
Add transition: background-image 300ms; in your CSS file. It’s better to add to the CSS file than to add CSS rules via javascript. Example CSS .header{ background: #333…
-
3
votes2
answers671
viewsA: Select with transition in change with onchange
What you need is an animation. In the example below use jQuery Animate and I can soon put another variant with Mootools. I leave comments on the code. Example: mostrador.animate({ opacity: 0 //…
-
6
votes1
answer517
viewsQ: z-index of an element without a closed position
It is possible to know the z-index of an empty element using javascript? For example in this code: CSS #exemplo1 { z-index:4; } #exemplo2 { z-index:4; position: relative; } HTML <div…
-
3
votes2
answers531
viewsA: Manipulating Array in PHP
In the while that has in your code you are always overriding the value of $valores and $referencia with each iteration, I think you want to use these variables as arrays. In this case you should use…
-
5
votes4
answers515
viewsA: Error with simple calculation in javascript
You need to convert to number using for example the parseint(). In javascript the sign + in kind string is to concatenate, in type number is to add. The amount you are receiving from .val() is a…
javascriptanswered Sergio 133,294 -
17
votes5
answers17254
viewsA: Generate multiple random numbers without repetition
The solution that occurs to me is to create an array and add to it the values already created/drawn, and look in the array if the value already exists before exporting a new one. This solution…
-
3
votes2
answers937
viewsA: How to animate the layout of Divs and caption, when doing Hover in one of these elements?
Here are two alternatives: #1 - using CSS Transitions for the background image url var linkImagens; var divImagens; $('.equipa_membro').hover(function () { divImagens =…
-
2
votes1
answer5119
viewsA: Transition effect on jQuery
You have two options: Using CSS Transitions in the background image. In this case we need an element divinstead of an image and this element is assigned a backgroung-image.…
-
3
votes2
answers131
viewsA: Pick singularly characters in a multiple string
William, try it like this: var str = "'C'; 'AEBDCEAB'; 'A'; 'B'"; var resultado = str.match("[a-zA-Z]{8}"); I used the function match. This will give an array where you can get what you want using…
-
20
votes4
answers20028
viewsA: Detect if an element contains a class with pure Javascript
In modern browsers it is possible to use the native property classList, thus the syntax will be: div.classList.contains("foo"); Demonstration at Jsfiddle This "new" classList property (English) is…
javascriptanswered Sergio 133,294 -
9
votes3
answers16413
viewsA: Run function after some time
Hmm interesting, here’s an idea that uses the setTimeout to trigger the animation after 400ms of the Hover. In case the mouse leaves, then the code clears the setTimeout and the code within the…
-
3
votes1
answer73
viewsQ: If / Else to defenir Environment variables in Travis
I am using Travis for javascript testing (Grunt/Karma) and set some variables in the file .travis.yml to run a test matrix. What I’m missing is a means of defining variables using an if/Else. I’m…
-
5
votes2
answers405
viewsA: How to make a constant object in Javascript
You can use the Object.() Object.freeze(object_teste); Example…
-
2
votes2
answers823
viewsA: Selecting a checkbox and not sorting the dataTables
Marcelo, I imagine the problem here is that the event click propagates to the parent element of input, to which dataTables ties an Event Listener to re-sort. So I think the important thing here is…
-
2
votes1
answer521
viewsA: Vertical bars valued with Flot.js
There is a plugin to do this. I found it a while ago when I was working on a adapting that I made from Flot to Mootools. The plugin link is: https://github.com/leonardoeloy/flot-valuelabels The new…
-
1
votes1
answer3276
viewsA: How to check radio button option and show corresponding HTML table
Here is a suggestion: $('input[type="radio"]').on('click', function () { $('.tabelaextra').addClass('escondida') $('#t' + this.id).removeClass('escondida'); }); Example In this example I did: I…
-
4
votes3
answers210
viewsA: timestamp does not indicate the correct date
By the example you’ve added to the question I see that $timeStamp is already a timestamp, then there’s no need for the strtotime(). Use only: echo strftime( '%A, %d de ' .$uppercaseMonth. ' de %Y',…
-
9
votes3
answers2277
viewsA: How to check if user has left the window
I think you can use the event blur Example using simple javascript: window.addEventListener('blur', function(){ // correr codigo aqui }); In the example apart from firing the event in the window…
javascriptanswered Sergio 133,294 -
2
votes4
answers8962
viewsA: I cannot do an onchange event to change a photo when we select the select field
Gustavo already gave a good answer (already accepted) about how to reference the element and selectIndex. I leave one more answer to add another way of thinking the code. So instead of using…
-
0
votes3
answers3057
viewsA: Smooth Transition in Image Slider
I suggest using CSS Transitions. So you don’t need Javascript to smooth the transition, you just need to add this to the CSS for the div #header-slider: -webkit-transition: background-image 0.7s…
-
5
votes1
answer412
viewsA: Undeclared variable error
The problem seems to me to be that the variable is not stated in cases where the condition of one of the ifis false. Both of this if (count($follow)){ as of this if ($user_id > 0){, a fail the…
-
3
votes1
answer2956
viewsA: Take the value of an image attribute and show it below
Try it like this: // iterar todos os li $('li').each(function() { // fazer cache do objecto para evitar funções a mais a correr // como o @Zuul referiu nos comentários var $this = $(this); // dentro…
-
4
votes1
answer1070
views -
12
votes2
answers991
viewsA: How to select element in the lowest hierarchical level?
Try to use it like this: $(document).ready(function () { $(document).on('click','.item', function (e) { // retirei o :last-child e.stopPropagation(); // impedir a propagaço do evento pelos li's…
-
1
votes2
answers506
viewsA: Onchange event not working when placed on the body
The problem here seems to be that HTML does not have what the selector was looking for. When you use: $('input[value="3"]:checked') Are you saying to track down elements like input whose value in…
-
6
votes1
answer298
viewsA: Problem setting CSS within style
The problem may be that the element has a closed CSS for a.bradC:link and you’re trying to force the color to a.bradC. In that case without the :link Since it’s not exactly the same rule, it might…
-
9
votes2
answers1901
viewsA: Event click Jquery in selector . class
Your intuition was correct, it’s using the this and the innerHTML. What is missing: You need a point in the jQuery selector for classes '.numero' ↑ (ponto aqui) Dynamically created elements need to…
-
8
votes3
answers465
viewsA: Hide image generated by Javascript
I suggest searching the images that have the shareit domain in their url (src) and hiding them. $('.sortEleWrapper img').each(function () { if (this.src.split('addthis.com/static/')[1])…
-
1
votes2
answers680
viewsA: jQuery Toggle Animation
Here is a suggestion: $(document).ready(function () { var aberto = $('#btn').is(':visible'); // verificar se #btn está visivel guardando o estado como true / false $('#admin > p').click(function…
-
3
votes1
answer253
viewsA: Disable link in jQuery paging menu
You can use Pointer-Events to prevent clicking on the elements that have this class. So in your class use: .no_more{ pointer-events: none; } You can read about more variants here, but I think CSS is…
-
4
votes2
answers166
viewsA: Customizing the Scroll of a div
Here’s a handmade example: $('div.img img').on('click', function () { var scrollDIV = $('#scrollDIV'); var scrollAtual = scrollDIV.scrollTop(); var novoScroll = scrollAtual + ($(this).hasClass('up')…
-
3
votes3
answers257
viewsA: Problem with Jquery UI Slide Left
The method .toggle() makes the div appear/disappear, it is better to use the method .animate() and encourage the margin-left for example. The width (width) could also be an alternative. So in order…
-
1
votes3
answers629
viewsA: How to capture innerHTML from a documentFragment via Javascript?
To MDN refers the method: element = documentframgment.querySelector(selectors); So an example would be: HTML <div id="test" contenteditable="true"> Teste <img src="/favicon.png" alt=""/>…
-
4
votes4
answers224
viewsA: Given a group of options, at least one should be selected, using jQuery
Here is another alternative $(function () { var checkGroup = $(".check-group"); checkGroup.on("click", function (e) { var marcadas = checkGroup.filter(function () { return this.checked; }); if…
-
8
votes3
answers5660
viewsA: How to keep the element scroll always at the bottom
You can use it like this to scrol: $('#wrap').animate({ // unsando o jQuery animate para animar o scroll scrollTop: $('#wrap ul').height() // fazer scroll para a posição correspondente à altura do…
-
3
votes2
answers6229
viewsA: Change image src through jquery
What you need is to run a code that changes the attribute src every image. Since you already have one vectorImagens, use like this: $('#ri-grid img').each(function(i){ vectorImagens[i] &&…
-
2
votes3
answers2397
viewsA: jQuery autocomplete shows no options
According to the plugin documentation, you need 2 fields (I assume mandatory) in the JSON object: An array of Objects with label and value properties: Translated: An array of objects with properties…
-
6
votes3
answers1952
viewsA: How to remove a website from Google?
Google often suggests/prefers removals to be done through useful information to bots (robots that go around the internet indexing content). I suggest four alternatives which can be used in addition:…
-
13
votes5
answers16269
viewsA: How to enable a button only when all inputs are completed?
The answer gets a little general without having specific code in the question. But here’s a suggestion: EDIT: I put a more modern version, the original version is down: var inputs =…
-
5
votes3
answers1752
viewsA: How to take the current position of a div by his class?
You can use it like this: var divs = $('.container .position'); divs.each(function (i) { this.setAttribute('data-index', i); }); divs.on('click', function () { console.log($(this).data('index'));…