Questions tagged as 'javascript'

4
answers

How to sort an array of objects with array.sort ()

How would I specify for the array.sort(); method how is the sort order? For example, I have an array of person objects, and person has name and number I wanted to sort by name. How would I specify this for my sort method?     
asked by 12.01.2015 / 19:41
3
answers

How to create functions in jQuery?

I would like to know the correct way, by following good practices, to create functions in jQuery. I've used it like this: var focusToEnd = function() { ... } And also like this: ; (function($) { $.fn.focusToEnd = function() {...
asked by 16.12.2013 / 20:23
3
answers

Remove page element with javascript

I'm making an application and I had a question: How can I remove an element from a page with javascript without using innerHTML = '' ? For example, I want to remove a div (like the example below) and all its contents: <div id="...
asked by 06.02.2014 / 17:04
8
answers

split / regex only on the first vertical bar "|"

I want to split the string into 2 parts (it will always be a array divide into two parts - or two elements) whenever a vertical bar | first case). For example: I have a string var string = "João|23anos"; I can give...
asked by 28.06.2017 / 19:45
3
answers

Format currency with thousands separator [duplicate]

I have the following code: function numberParaReal(numero){ var formatado = "R$ " + numero.toFixed(2).replace(".",","); return formatado; } function realParaNumber(texto){ var compativelComParseFloat = texto.replace("R$ ","");...
asked by 06.03.2017 / 17:37
3
answers

jQuery - Typical duplicate use situation of the same code. How to proceed?

Being here doing my sites in php/mysql/html/css and learning more and more about jQuery I got into the situation where I should use the same code for two ids distinct. How do I need to use the same code in two different p...
asked by 09.08.2014 / 20:05
2
answers

Check if parentheses have been closed

I need a Regex that checks whether the parentheses have been closed within the string . This is my example: /regex/.test("fdfdfdf(ddsd"); //retorna false, porque o parentese nao foi fechado;. /regex/.test("fdfedff(ffd)dd") //retorma true...
asked by 10.08.2014 / 21:36
4
answers

How to replace the src of an img tag?

I have an html page that shows an image for each day of the year. Images are organized into folders such as /img/o1/o1.jpg (referring to January 1st), and so on. My html is simple I want you to take the day + month today and replace...
asked by 28.03.2014 / 03:58
2
answers

How to get an attribute of several "tags" with same ID

Hello, when I click on one of the 3 options in "HTML" that is in the code below, I want the function in "JS" to issue an "alert" with the "idPost" in which it was clicked. EX: When I click on the link "PHP" it issues an alert 25, which would be...
asked by 22.04.2015 / 01:52
2
answers

Capturing audio via microphone via JS or HTML

I need to capture audio from the microphone and write to file. Send to PHP server. How do I, in the examples I saw here, did not notice how to record the sound files.     
asked by 30.04.2014 / 23:31