Reputation: 187
can i use javascript and jquery both in a page?
like:
<script type="text/javascript">
$(document).ready(function(){
//some jquery
});
function xyz(){
//javascript statements
//some jquery statements
}
</script>
Upvotes: 1
Views: 246
Reputation: 382696
Yes they can because both are basically the same. JQuery is just a framework of JavaScript; so no problem there :)
Upvotes: 2
Reputation: 17617
Also jQuery is written in an anonymous scoop. Which means that you even can call your functions the same thing since all jQuery's functions (methods) is under the jQuery namespace.
Ie.
//In jQuery there's a method called "extend"
$.extend( obj : newObj);
// This can co-exists with you own global "extend" method
function extend () {
//do stuff
}
..fredrik
Upvotes: 0
Reputation: 10680
Yes, jQuery is a library that provides more out-of-the-box functionality, but it's still Javascript.
You'll still be able to use the base language if you choose. Be aware that jQuery will afford you many opportunities to refactor existing code for brevity and maintainability.
Upvotes: 3
Reputation: 24351
jQuery is a Javascript library so whenever you're using it on a page, you're already using Javascript. So yes, you can.
Upvotes: 3
Reputation: 6830
jQuery == javascript
so Yes, javascript functions can co-exist with jQuery functions, just use the correct namespace for the function you want to call...
Upvotes: 3
Reputation: 103135
Yes. jQuery is JavaScript. jQuery simply provides some very convenient functions that takes care of some of the pain of writing JavaScript.
Upvotes: 11