I'm creating input field dynamically in my page with some id like #MyField
And when I try to catch click event by $('#MyField').click(function (){})
it doesn't work!
Am I do it in wrong way?
Asked
Active
Viewed 23 times
0

Mohammad
- 69
- 10
-
1try this `$('#MyField').on("click", function (){})` – Pankaj Makwana Sep 06 '17 at 12:27
-
2https://stackoverflow.com/questions/6658752/click-event-doesnt-work-on-dynamically-generated-elements – XYZ Sep 06 '17 at 12:27
-
define doesn't work. – Sumi Straessle Sep 06 '17 at 12:27
-
1@PankajMakwana: That's just the long form of the shortcut form the OP used, it's functionally identical. – T.J. Crowder Sep 06 '17 at 12:28
-
share your code – Subhabrata Mondal Sep 06 '17 at 12:29
-
@T.J.Crowder see the comment from Sujith – Sumi Straessle Sep 06 '17 at 12:29
-
@Sujith well seen! I learned something today. – Sumi Straessle Sep 06 '17 at 12:29
-
1@SumiStraessle: I already closed this as a dupe of the *previous* question that that one should have been closed as a dupe of (and now has been). – T.J. Crowder Sep 06 '17 at 12:30
-
try this `$(document).on("click", '#MyField', function (){})` – Pankaj Makwana Sep 06 '17 at 12:35