Wasabi
Wasabi

Reputation: 1591

Using JS Methods in jQuery

In the following code snippet, the String.fromCharCode is used, can all JS methods be used within jQuery?

Perhaps a noob question, but better to ask and prove a noob, then assume and be a fool.

 // Invoke setBodyClass when a key is pressed
$(document).keyup(function(){
    switch (String.fromCharCode(event.keyCode)){
      case 'D':
        setBodyClass('default');
        break;
      case 'N':
        setBodyClass('narrow');
        break;
      case 'L':
        setBodyClass('large');  
        break;
    }

});//end keyup

Upvotes: 2

Views: 84

Answers (7)

Mike DeSimone
Mike DeSimone

Reputation: 42845

can all JS methods be used within jQuery?

Yes. jQuery is a library, not a replacement language.

Upvotes: 1

Tim B James
Tim B James

Reputation: 20374

Yes. jQuery is a javascript library

Upvotes: 1

Sampson
Sampson

Reputation: 268512

jQuery is Javascript, so you may use any type of Javascript logic with jQuery.

Upvotes: 3

T.J. Crowder
T.J. Crowder

Reputation: 1075925

can all JS methods be used within jQuery

Yes. jQuery is just a library of JavaScript functions.

Upvotes: 2

Loktar
Loktar

Reputation: 35319

Yes since jQuery IS JavaScript any and all JavaScript can be used in conjunction with it.

Upvotes: 1

Peter Olson
Peter Olson

Reputation: 143037

Yes, all javascript functions can be used with jQuery. jQuery is just a plug-in that adds to javascript.

Upvotes: 1

hvgotcodes
hvgotcodes

Reputation: 120318

in one word -- absolutely. And I think the only stupid question is the one not asked.

Upvotes: 3

Related Questions