views:

91

answers:

6

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>
+11  A: 

Yes. jQuery is JavaScript. jQuery simply provides some very convenient functions that takes care of some of the pain of writing JavaScript.

Vincent Ramdhanie
Thanks all. I expected some replay tomorrow, but i am delighted with these answers within minutes. Thank you all and stackoverflow.
Kumar
Why not accept an answer then? :)
Paul Alan Taylor
+3  A: 

jQuery == javascript

so Yes, javascript functions can co-exist with jQuery functions, just use the correct namespace for the function you want to call...

Nicky De Maeyer
+3  A: 

jQuery is a Javascript library so whenever you're using it on a page, you're already using Javascript. So yes, you can.

Timo Geusch
+2  A: 

Yes they can coz both are basically same. Jquery is just a framework of javascript; so no problem there :)

Sarfraz
+3  A: 

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.

Paul Alan Taylor
A: 

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

fredrik