I am working with jQuery 1.7.2.
I have create a custom plug-in that loads a modal – i.e., a div with content. ($modal)
When the div is shown to the user, I would like to bind a function to all anchor tags in the div that has the class Close assigned to it.
I have something like this:
$(".Close", $modal).die().on("click", hitMe());
The problem I am having is that every time the div loads, the hitMe() function is always firing. I only want this to fire when the user clicks an anchor in the div with class Close.
Any idea where I am going wrong with this?
You are calling hitMe inside the .on function.
What you need to do is pass the function as an argument