-3

I added a div element into a variable and appended it to the document:

var faceDiv = $("<div class='dropDownJsFace dropDownJsArrowDown' />");

Now I'm attempting to reference that div within the .on() function via e.target like so

$(document).on("click", function(e){
    if(e.target == faceDiv)
    {
        alert("done");  
    }
});

To clarify, I want it to specifically reference that dynamically created div, as apposed to the class .dropDownJsFace.

Majo0od
  • 2,130
  • 9
  • 31
  • 51

1 Answers1

0

Just use the selector parameter to .on:

$(document).on("click", "div.dropDownJsFace", function(e) {
        alert("done");  
});
James McLaughlin
  • 18,774
  • 3
  • 47
  • 56