Kumar
Kumar

Reputation: 187

can jquery and javascript co-exist in a file?

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

Answers (6)

Sarfraz
Sarfraz

Reputation: 382696

Yes they can because both are basically the same. JQuery is just a framework of JavaScript; so no problem there :)

Upvotes: 2

fredrik
fredrik

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

Paul Alan Taylor
Paul Alan Taylor

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

Timo Geusch
Timo Geusch

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

NDM
NDM

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

Vincent Ramdhanie
Vincent Ramdhanie

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

Related Questions