Asked  7 Months ago    Answers:  5   Viewed   37 times

I bind two event handlers on this link:

<a href='#' id='elm'>Show Alert</a>



function _f(){alert('clicked');}
function _m(){alert('mouse over');}

Is there any way to get a list of all events bound on an element, in this case on element with id="elm"?



In modern versions of jQuery, you would use the $._data method to find any events attached by jQuery to the element in question. Note, this is an internal-use only method:

// Bind up a couple of event handlers
    click: function(){ alert("Hello") },
    mouseout: function(){ alert("World") }

// Lookup events for this particular Element
$._data( $("#foo")[0], "events" );

The result from $._data will be an object that contains both of the events we set (pictured below with the mouseout property expanded):

Console output for $._

Then in Chrome, you may right click the handler function and click "view function definition" to show you the exact spot where it is defined in your code.

Tuesday, June 1, 2021
answered 7 Months ago

For images there's now context.imageSmoothingEnabled= false.

However, there's nothing that explicitly controls line drawing. You may need to draw your own lines (the hard way) using getImageData and putImageData.

Tuesday, June 1, 2021
answered 7 Months ago

You can wire up your own custom event

   //do stuff here
    if(e.keyCode == 13)

Saturday, August 7, 2021
answered 4 Months ago

These events bubble up, so if you're trying to trigger the event wherever your focus is (ie. not in an input), just bind a handler on window:

$(window).keypress(function (e) {
  if (e.key === ' ' || e.key === 'Spacebar') {
    // ' ' is standard, 'Spacebar' was used by IE9 and Firefox < 37
    console.log('Space pressed')

Also see the list of all .key values.

Monday, September 13, 2021
Success Man
answered 3 Months ago

To summarise, you appear to want :

  • on touchstart: to display and position a styled div element.
  • on touchmove: to drag the element without releasing and re-pressing the mouse button.

If this interpretation is correct, then the answer is to to handle touchmove events on the same element that was originally clicked on - namely the "body" element. It is not necessary to handle touchmove events of the element you want to drag (the added element).

There must be many ways to write the code. Here's one, which is probably not exactly what you want (chiefly in the positioning maths) but should be simple to adapt :

var $element = $("<div class='element' />");

    'touchstart mousedown': function (e) {
        $(this).on('touchmove mousemove', move);
        move(e);//you could do `$(this).trigger('touchmove', e)` but a conventional function call keeps `move` simple.
    'touchend mouseup': function (e) {
        $(this).off('touchmove mousemove');

function move(e) {
        left: (e.pageX - 10) + 'px',
        top: (e.pageY - 10) + 'px',
        cursor: 'pointer'

mousedown/mousemove/mouseup allow for desktop testing and can be removed for touch device usage.


Tuesday, October 12, 2021
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :