jQuery click vs onClick

0 votes

I have a huge jQuery application, and I'm using the below two methods for click events.

First method

HTML

<div id="myDiv">Some Content</div>

jQuery

$('#myDiv').click(function(){
    //Some code
});

Second method

HTML

<div id="myDiv" onClick="divFunction()">Some Content</div>

JavaScript function call

function divFunction(){
    //Some code
}

I use either the first or second method in my application. Which one is better? Better for performance? And standard?

May 27 in Java by Edureka
• 13,640 points
27 views

1 answer to this question.

0 votes
So, using a string that is tied to a function, onclick produces an attribute within the binded HTML tag. . click, on the other hand, attaches the function to the property element.
answered May 30 by gaurav
• 13,460 points

Related Questions In Java

0 votes
0 answers

jQuery.click() vs onClick

I have a huge jQuery application, and ...READ MORE

Feb 8 in Java by Rahul
• 8,980 points
25 views
+1 vote
1 answer

concat() vs “+” operator : In Java for String concatenation

Basically, there are two important differences between ...READ MORE

answered Apr 27, 2018 in Java by Rishabh
• 3,620 points
3,206 views
0 votes
1 answer

HashMap vs LinkedHashMap vs TreeMap

Hi, there is no as such difference ...READ MORE

answered May 5, 2018 in Java by v.liyyah
• 1,300 points
809 views
0 votes
1 answer

Comparable vs Comparator in Java

I think you are not alone who is ...READ MORE

answered May 11, 2018 in Java by code.reaper12
• 3,500 points
414 views
0 votes
1 answer

@Component vs @Repository vs @Service in Spring Framework

As you might be knowing, all these ...READ MORE

answered May 29, 2018 in Java by geek.erkami
• 2,680 points
2,535 views
0 votes
2 answers

C++ performance vs. Java/C#

The overhead of interpreting code is much higher than ...READ MORE

answered Dec 27, 2018 in Java by iangregor
• 300 points
440 views
+1 vote
1 answer

Performance difference of if/else vs switch statement in Java

The thing you are worried about is ...READ MORE

answered Jul 26, 2018 in Java by geek.erkami
• 2,680 points
2,105 views
0 votes
1 answer

Java Timer vs Executor Service

According to Java Concurrency in Practice: Timer is ...READ MORE

answered Jul 26, 2018 in Java by code.reaper12
• 3,500 points
4,107 views
0 votes
1 answer

Wait until all jQuery Ajax requests are done?

You may need to run certain code ...READ MORE

answered May 30 in Java by gaurav
• 13,460 points
28 views
0 votes
1 answer

Google AJAX Libraries CDN for jQuery

The Google Hosted Libraries is a stable, ...READ MORE

answered May 30 in Java by gaurav
• 13,460 points
45 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP