-1

I'll keep my question short. I've read this question about a delay function.

How to wait 5 seconds with jQuery?

and it struck me that people wanted to know about alternative ways to achieve this using JQuery.

In my understanding JQuery is nothing but a JS library. In many cases to introduce new functionality.

Now why would someone use JQuery if an original JS function is available and not even too complex?

Bonus question: Can JS functions be called from within JQuery? (this one, if negative might answer my first one, actually...)

Community
  • 1
  • 1
Neil S3ntence
  • 198
  • 2
  • 19
  • 1
    Your question is primarily opinion-based and does not actually have any specific problem statement. However, to answer your question, jQuery handles cross-browser compatibility better (e.g. the `$(document).ready()` function is way more complicated than you think, with various fallbacks) and also simplifies selection of DOM elements. It has native animation and effects queue built it, something that would probably require excessive work in native JS. – Terry Feb 12 '15 at 01:26
  • 2
    Many times I use JQuery even if a native JS function exists. My reasoning has to do with ensuring cross-browser compatibilities (which have been mostly dealt with when using a popular library such as JQuery). Obviously, not for the most basic of native calls (i.e. addition, concatenating strings, etc) but even the most basic ajax call can trip me from time to time due to nuances from browser to browser. – blurfus Feb 12 '15 at 01:26
  • Since jQuery is simply an extension, not a modifier, of JS, you can always call JS functions within jQuery. – Terry Feb 12 '15 at 01:27
  • 1
    I'm not an expert on JQuery / JS. In fact I'm a beginner. I didn't say that I'm looking for opinions, however, most answers are based on opinion as opinion may be itself based on experience + facts. I wouldn't even exclude opinion per se, as there are opinions with a rationale behind them. I was hoping that, instead of voting down my question, it could be up to me to look for the kind of answer I need. – Neil S3ntence Feb 12 '15 at 03:15
  • 1
    I was looking for real reasons why it would make sense to use JQuery. I was thinking there might be things that *aren't possible* with pure JS or the other way around. Thank you all for the answers/comments. It's is going into the direction of the kind of info I was looking for. – Neil S3ntence Feb 12 '15 at 03:15

1 Answers1

4

In my understanding JQuery is nothing but a JS library. In many cases to introduce new functionality.

Yes, that is correct. In fact, your astute observation that people want to use jQuery where JS will suffice likely stems from a lack of understanding to this point!

Now why would someone use JQuery if an original JS function is available and not even too complex?

Someone may wish to use jQuery for certain functions if the JS-only equivalent is not well supported in all browsers.

Bonus question: Can JS functions be called from within JQuery? (this one, if negative might answer my first one, actually...)

Certainly! As you stated, jQuery is just a JavaScript library, and can be mixed with bits of plain JS without a problem.

mjswensen
  • 3,024
  • 4
  • 28
  • 26