Samuel Charpentier
Samuel Charpentier

Reputation: 609

.click event don't work on a certain div ID conflict?

I try to execute a function when I click on a specific div ID and nothing happens, help! Example:

$( "#jwplayer-1_wrapper" ).click(function() {
  alert( "Handler Clicked" );
});

-> Full example here <-

Upvotes: 0

Views: 140

Answers (4)

Harsha Venkataramu
Harsha Venkataramu

Reputation: 2914

Check this

http://jsfiddle.net/2mK7Z/22/

$(document).ready(function(event)
{
    $('#jwplayer-1_wrapper').mousedown(function() {
      alert('click detetced');
    });
});

Upvotes: 2

Pedro Moreira
Pedro Moreira

Reputation: 975

You have to wait for the DOM to become ready. Use jQuery(document).ready

$(document).ready(function() {
   $( "#jwplayer-1_wrapper" ).click(function() {
     alert( "Handler Clicked" );
   });
});

Upvotes: -1

andrel
andrel

Reputation: 1154

I think this is the problem you are experiencing: Track a click on a flash movie (object / embed) with jQuery

That is - the embedded flash object steals the click event, and jquery will never see it.

Upvotes: 1

Daniel Bernhard
Daniel Bernhard

Reputation: 382

Do you create the element dynamically? It could be that the element doesn't exist at document ready. Try:

$("body").on("click", "#jwplayer-1_wrapper", function() {
  alert("Handler clicked");
})

Otherwise, check the ID and make sure it's correct.

Upvotes: 0

Related Questions