Answer by Regent for Getting id of an element in jQuery using a function
.click() is supposed to get Function, not String as parameter.It should be:$('#myButton1').click(myfunction);Fiddle.
View ArticleAnswer by Moob for Getting id of an element in jQuery using a function
When you click on myButton1 the JS is unable to dispatch the event and throws TypeError: undefined is not a function because you are calling it incorrectly. Your browser may however register the click...
View ArticleAnswer by Rahul Tripathi for Getting id of an element in jQuery using a function
Try this:-$('#myButton1').click(function(){ console.log(this.id);});
View ArticleAnswer by James Donnelly for Getting id of an element in jQuery using a function
Your #myButton2 example is accurate. You need to use this.id to get the ID of the element which the event has been fired on:$('#myDiv').click(function() { alert(this.id);});However this isn't clicking...
View ArticleAnswer by Rob Schmuecker for Getting id of an element in jQuery using a function
$('#myButton1').click(function(){myfunction(this)});myfunction = function(e){ alert(e.target.id); e.stopPropagation(); }
View ArticleGetting id of an element in jQuery using a function
I have a simple code with two buttons in a div container. I want to get the id of a button using a function.Problem: Can someone please explain why clicking on Button1 doesn't alert myButton1? How can...
View Article
More Pages to Explore .....