Skip to content
Advertisement

jQuery $(event.target) returns DOM in console, not HTML

With this code: I expect to see: but instead get: [span.icon-tag docs-tag child_hover dropdown-open, context: span.icon-tag docs-tag child_hover dropdown-open, constructor: function, init: function, selector: “”, jquery: “1.8.2”…] I have recently upgraded to jQuery 1.8.2. Has there been a change in how $(event.target) is handled? Answer This has to do with changes in the browser output, it doesn’t have to do

Prevent, then re-trigger a JavaScript event?

I’ve got an event handler set on document, listening for submit and change events, delegated to any form elements on the page. The idea is to update the server when an input is altered (since the event bubbles up to the form), while also allowing for submitting an entire form. I have a few overrides in place for inputs that

Handling several .one on same event and element

I have a custom animation framework that uses CSS transitions. In order to allow for callbacks I attach: However, some of the same event listeners are fired again and again (yes, it’s actually the same functions with the same guids, I checked). It seems the .one is not properly removing it again. I’ve tried making a small test-fix with a:

Javascript ascii string to hex byte array

I am trying to convert an ASCII string into a byte array. Problem is my code is converting from ASCII to a string array and not a Byte array: This results in: But what I am looking for is: How can I convert to a byte rather than a byte string ? This array is being streamed to a USB

Detect user exit site

I have an urge to detect when a user leaves my site in order to record accurately the session length of the user in question. I have thought of a couple possible solutions for this: I first thought I could use onbeforeunload and send a simple ajax to record the last activity but what practice has shown me is that

Check if class exists somewhere in parent

I want to check if a class exsits somewhere in one of the parent elements of an element. I don’t want to use any library, just vanilla JS. In the examples below it should return true if the element in question resides somewhere in the childs of an element with “the-class” as the class name. I think it would be

How to wait for div to load before calling another function?

I’m loading subpages to a selected div of my main page by a jQuery function. In order to synchronise main div’s and right column’s height I’m using jQuery’s .css() method. I wanted that resizing to look smoothly, so I’ve resolved it to following steps: 1. Load content of a subpage to an invisible temp div. 2. Calculate the height of

JavaScript function nearest geographical neighbor

I am looking for a JavaScript function who returns the nearest neighbor of a number. e.g: I am having a coordinate 12,323432/12,234223 and i want to know the nearest coordinate of a set of 20 other coordinates in a database. How to handle that? Answer The following 3 functions find the nearest coordinate from a javascript array using the Haversine

OnClick Send To Ajax

I’m trying to complete some ajax requests to insert a textarea into a database without refresh. Here is my code: HTML: JS: My Questions: 1) How do I send the contents of the text area into the onclick function? 2) How do I escape/urlencode etc.. So it retains line breaks Answer You have few problems with your code like using

Advertisement