-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,278
  • 10
  • 33
  • 58

1 Answers1

0

Just use the selector parameter to .on:

$(document).on("click", "div.dropDownJsFace", function(e) {
        alert("done");  
});
James M
  • 18,506
  • 3
  • 48
  • 56