Skip to content

Tag: jquery

How to detect element being added/removed from dom element?

Say I had a div#parent and I append and remove elements to it using jquery. How would I be able to detect when such an event happens on the div#parent element? Answer Use Mutation Observers as suggested by @Qantas in his answer Following methods are deprecated You can use DOMNodeInserted and DOMNodeRemoved MD…

Select2() is not a function

So i have downloaded select2 i have “installed it” by putting it into my folder and then loaded it on my site when i check the console (where i can see all of the scripts being loaded) i can see the file select2.js I went to their documentation and copied it and added $(“#e9”).select2(…

Use Javascript to create dynamic input id

I want to use javascript to create <input/> tags with a dynamic id (name attribute will be the same) depending on the order in which they appear. I have the first <input/> tag in plain html and a div that should append a new <input/> with an incremented id when clicked: Now, the javascript n…

iPhone vs Javascript event suppression

I’ve got a simple click handler that does something on the screen instead of visiting that link. Here’s the code (I’m cutting out the nonsense but the important stuff is accurate): This works fine on proper browsers. It works fine on Android (both older webkit and newer Chrome builds) and it…

divide number with decimals javascript

how can I divide number (money) to x number equally the number could be with one or two decimal or without it such as 1000 or 100.2 or 112.34 I want to be able to split that number into x part all of them equally, however if it’s not odd number the extra number to the last one. for example

socket.io – socket.on wait for promise

I have a button that does some communication with the server to check if an entered value (via an input box) already exists. The code is the following: The problem is that the checkReturn call is asynchronous, and therefore the code carries on without actually waiting for the result. How do I make sure that c…