Posts by BrTkCa • 11,094 points
375 posts
-
8
votes4
answers5283
viewsA: Separate an array into groups?
You can optimize the function a little using Array#Slice. Upshot: function separar(base, max) { var res = []; for (var i = 0; i < base.length; i = i+(max-1)) { res.push(base.slice(i,(i+max))); }…
-
1
votes1
answer144
viewsA: Text form in $('span.text'). text();
Exchange the text for html: $('span.texto').html('Enviamos um email para <b>email@email</b'); <script…
-
2
votes6
answers2251
viewsA: Remove all elements from an array that already exist in another
Another option is to remove the index from the array itself: var a = [{a: 1}, {b: 1}, {c:1}, {d:1}, {e:1}]; var b = [{b:1}, {e:1}]; a.map(function(item, index){…
-
5
votes3
answers4549
viewsA: Align span right inside div
It is possible using display: table, and defining rows and columns to be tabulated, and then aligning the texts of each column. Example #tabela { display: table; background-color: gray; color: #fff;…
-
1
votes2
answers499
viewsA: Select record that has a date field using only the year on Where
You can use the function Year: SELECT * from tabela WHERE YEAR(campo_data) = '2017' Or Extract: SELECT * from tabela WHERE EXTRACT(YEAR FROM campo_data) = '2017' If you’d better use Date or Varchar…
-
2
votes1
answer389
viewsA: Pass a javascript parameter in the middle of an append
You won’t be able to get HTML to pass an entire object to the function, I suggest you pass as argument the full text object. Example var data = [{ nome: 'Lucas', telefone: '12', cep: '123',…
-
0
votes2
answers825
viewsA: How to redeem checkbox value in the form using serialize()?
An alternative is to get the values of checkboxs and concatenate with the method serialize, since serialize() transforms the form values into a querystring valid: jQuery('#form').submit(function(){…
-
1
votes2
answers321
viewsA: Show Image before saving to bank
To view the image after it is selected, it is possible with the API Filereader: Example: function mostraImagem(img) { if (img.files && img.files[0]) { var reader = new FileReader(); var…
-
0
votes4
answers188
viewsA: Increment in Javascript function
I just modified where the counter is applied so as not to run away from what you thought: (function($) { RemoveTableRow = function(item) { inicio--; var tr = $(item).closest('tr'); tr.fadeOut(400,…
javascriptanswered BrTkCa 11,094 -
4
votes1
answer103
viewsA: click() does not recognize button inserted dynamically inside tr
You can use: $(document).on("click", "table#tb-itens tbody tr button[type=button]", function (){ alert($(this).val()); }); That way, using delegated events, there is the advantage of being able to…
-
3
votes1
answer7860
viewsA: How to align elements within a DIV to the left of it
Changing the property justify-content for left: justify-content: left; .episodesContainer { width: 90%; height: auto; background: rgba(105, 203, 115, 0.5); margin-top: 40px; margin: 0 auto; display:…
-
0
votes2
answers3740
viewsA: how can I use group by next to order by
Untested, but I believe you can separate the ordination into a subselect: SELECT * FROM ( SELECT nome_fotos, img, id_cliente, id_fot FROM alboom WHERE id_fot = '$getid' ORDER BY id_cliente ASC ) AS…
-
1
votes2
answers979
viewsA: How to add object property in Array to *ngFor
I suggest you process the total in the controller, it could be like this: var order=[ {"qtd": Number(1),"vlr":Number(3.50)}, {"qtd": Number(6),"vlr":Number(4.00)}, {"qtd":…
-
0
votes1
answer71
viewsA: Align text after choosing an option in select
You can hide the elements that are not targets, this way: $('select[name="list_citys"]').change(filterList); function filterList(e) { var value = e.target.value; $(".list_citys_shop…
-
0
votes1
answer400
viewsA: Validate more than one input CPF field
I noticed you’re using jQuery, I believe you can do it that way: $(document).on('blur keyup', "input[name^='cpf']",function() { $("#resposta").html(CPF.valida($(this).val())); }); ^ is a criterion…
-
1
votes2
answers250
viewsA: Concatenate string to all href of the page
To change the value can be something like: $('a').each(function(index,item){ var link = $(this).prop('href') + "#pr"; $(this).prop('href', link); }); <script…
-
3
votes1
answer1043
views -
0
votes2
answers72
viewsA: Selector in CSS differences
.A>.B>.C will select C who is B’s immediate son who is A’s immediate son .A .B .C will select C and B for any offspring
-
0
votes2
answers110
viewsA: Adjust only one component
To select the element by id you must sweat #: HTML: <input id='id_do_elemento'> CSS: #id_do_elemento{ padding:0; background-color: red !important; } This way this style will be applied only to…
-
4
votes3
answers2919
viewsA: Define multiple "id" in an HTML tag
Multiple ids per item is not allowed: The value of this attribute must not contain gaps (spaces, tabulations etc.). Browsers treat inappropriate Ids that contain gaps such as if the gaps were part…
-
1
votes1
answer851
viewsA: Reload table without refresh with Ajax jQuery
If you choose to rebuild the table, you could remove the content from tbody and render again with the return of jQuery ajax. Something like: success: function (result) { $('tbody').empty();…
-
1
votes1
answer77
viewsA: JAVA and Javascript
There is a significant difference between the framework Node.js and Java which is the fact that Java is a strongly typed language while Node.js (Javascript) does not. The way objects are created and…
-
6
votes2
answers815
viewsA: How to take text inserted into an input and insert it into a label ?
document.getElementsByClassName("loginBtn")[0].addEventListener('click', function(event) { document.getElementById("txtEmail").innerHTML = document.getElementById("email").value; }); <div…
-
7
votes3
answers425
viewsA: Difference between '$()' and 'jQuery()'
$() is an alias for jQuery(). Many javascript libraries use $ as function or variable names just like jQuery does. See the reference of jQuery.noConflict()…
-
0
votes1
answer997
viewsA: Logico Javascript Operator Error on JSF page
You will need to escape the XML entities. <h:outputText value="Tom & Jerry" /> This problem is not related to the JSF itself, but with the visualization technology, you would need to…
-
0
votes1
answer118
views -
2
votes1
answer222
viewsA: How to make small animation with js
You can leave a div with the hidden texts, and display when the mouse passes over, using Transitions in css to , something like: #content { position: relative; background-color: green; overflow:…
-
1
votes1
answer78
viewsA: Gson Return Array of One Position
No need to use Gson for this. You can do: return "\"{'nome' :'"+ cadastro.getNome()+"'}\""; Using scapes for the string to go with the quotes.
-
1
votes2
answers609
viewsA: Add +1 to an Id when adding fields dynamically
You can concatenate the name with a counter: var cont = 1; var nome = 'Teste'; function mostrar(){ document.getElementById("res").innerHTML = nome + cont++; } <button…
javascriptanswered BrTkCa 11,094 -
2
votes3
answers234
viewsA: Should I set the background on TD or TR?
One difference I see between the two is that applying the style to the line will always be the whole line, having as an advantage build an effect "zebra": .table>thead>tr:nth-child(odd) {…
-
4
votes3
answers3378
viewsA: How and how to best use CSS fonts?
With as many font types as: Rif, Monospace and others, which type should I wear Font type is based on opinion when using Rif, Monospace or other. How to use an original, different font but ensure…
-
2
votes1
answer395
viewsA: Detect event click out of element
You can use the property target in the click of the document: window.addEventListener('click', function(e) { if (!document.getElementById('banner-tooltips').contains(e.target)) { var anterior =…
-
2
votes1
answer135
viewsA: Tooltip function does not work when running a second time
Probably in the first click has no element with the class banner-tooltip-active, but in the second yes, and this error is generated because document.getElementsByClassName("banner-tooltip-active");…
-
1
votes1
answer27
viewsA: Detecting click elements of an array
You can iterate all the span and add the event click: var caixaTooltips = document.getElementById("banner-tooltips"); var tooltips = caixaTooltips.querySelectorAll("span"); for (let i = 0 ; i <…
-
2
votes2
answers587
viewsA: enable input button
To enable the correct button is to put some event in #cat, as change for example: $(document).ready(function() { $("#sendCat").prop('disabled', true); }); $("#cat").change(function(a) { let botao =…
-
4
votes2
answers79
viewsA: Separate the string value
You can break the string comma in this case, and take the first index: let texto = '24.95, <strong> Outro texto, </strong>'; let valor = texto.split(','); console.log(valor[0]);…
-
1
votes3
answers9803
viewsA: How to pick up values contained in a table?
id is an attribute that cannot be repeated, apart from not being semantic, document.getElementById will always return only one element. I suggest changing to any other selector (like class for…
-
2
votes3
answers663
viewsA: Method Object.values( ) does not work in internet explorer 9
Object values. is not supported by Internet Explorer, as you can see in this table: For more compatibility, use for. in: var obj = {a:1, b:2, c:3}; var array = []; for (var propriedade in obj) {…
javascriptanswered BrTkCa 11,094 -
1
votes2
answers1110
viewsA: Rename a variable using Function /Javascript Parameters
Javascript has objects, based on keys and values such that I believe to be most useful for what you are trying to do. This way, it is possible to add n keys, and then recover in various ways. Based…
javascriptanswered BrTkCa 11,094 -
1
votes2
answers1131
viewsA: Javascript sum or subtract by clicking checkbox
With javascript, to avoid code redundancy it is possible to insert an event in all checkbox, something more or less like: var inputs = document.querySelectorAll('input[type="checkbox"]'); for (let i…
javascriptanswered BrTkCa 11,094 -
2
votes2
answers54
viewsA: Change Word by clicking on it
You can add an event from click using as selector the class input-group-addon to select the div, and amend the text: document.querySelector('.input-group-addon').addEventListener('click',…
javascriptanswered BrTkCa 11,094 -
2
votes1
answer664
viewsA: Show age between 20 and 30 in an array - Avascript
One way is to use the Array#filter javascript to filter only people who enter the age criterion: var pessoas = [{ nome: 'Diego', age: 17, }, { nome: 'Natalia', age: 12, }, { nome: 'David', age: 27,…
-
1
votes1
answer98
viewsA: HTML scrapping with pure Javascript
var links = document.getElementsByTagName('links'); for (let i = 0 ; i < links.length ; i++){ console.log(links[i].innerHTML); } <links…
-
0
votes2
answers370
viewsA: How to capture the value of the src attribute of an iframe?
With jQuery, you can use the method meet: $('#meuframe').contents().find('#video_html').attr('src');…
-
0
votes1
answer201
viewsA: Datatable library conflicting on Other script
You can try using noConflict() jQuery: $.noConflict(); jQuery( document ).ready(function( $ ) { // });…
-
0
votes1
answer658
viewsA: save in file a return from backend
In the function you are calling (e.g., callback of an ajax request), you can create a file from blob, associate the address to a link and download, something like: function download(data){ var a =…
-
1
votes1
answer841
viewsA: How to load image from javascript using Base64?
With jQuery, you can change the source of the image using attr or prop: var imagem = 'data:image/jpeg;base64,/9j/...'; $("algum_seletor").attr('src', imagem); With this it is possible to apply some…
-
3
votes2
answers908
viewsA: How to perform an internal search for the id?
function busca() { var str = document.getElementById('txt').value; var obj = document.getElementsByTagName('div'); var existe =…
javascriptanswered BrTkCa 11,094 -
1
votes3
answers1453
viewsA: $. getJSON - How to store responseJSON in a Variable?
$.getJSON is asynchronous, so the value returned by it will be undefined on the next line, and also the responseJSON will be inside dicio. I suggest you perform the next operations inside the…
-
0
votes1
answer75
viewsA: Why doesn’t this function work in Mobile Browser?
Maybe the problem is Object.values, you can try replacing by for. in: var valores = []; for (property in meu_json){ valores.push(meu_json[property]); } var data = valores.filter(function(objecto) {…