0

I'm reading the JavaScript Bible, trying to learn JavaScript like a good jQuery developer. But the problem with reading a JavaScript reference is that I don't know which objects have been replaced by jQuery (example: getElementsByTagName, getUserData) and which ones haven't.

For instance, is there a "getFeature" replacement in jQuery?

I can imagine the .attr() could be used as a replacement for hasAttribute().

I'd like something with two columns, the left-hand column a jQuery property/method, the right be the JavaScript property/method(s) it replaces so that it tells me "don't worry about these parts, they're not the good parts".

Community
  • 1
  • 1
Phillip Senn
  • 46,771
  • 90
  • 257
  • 373
  • 2
    At times you may still need to just use the javascript functions, jQuery makes Javascript easier, but it isn't a replacement, so learn javascript, then learn jQuery, as it can make life easier. – James Black Mar 27 '11 at 03:06
  • I agree that I need to learn JavaScript, but I will never ever in my life ever use getElementById period. And I mean it. – Phillip Senn Mar 27 '11 at 03:41

2 Answers2

4

You are looking at this the wrong way. Look at it like this: JavaScript first, jQuery second. jQuery doesn't completely redo everything JavaScript has done, just makes it easier to do. It has it's own personality, but kind of "wraps over" some common JS functions, so to say.

For example:

getFeature becomes: http://api.jquery.com/jQuery.support/

getAttribute, setAttribute, and hasAttribute becomes: http://api.jquery.com/attr/

document.getElementById("special") becomes: $("#special") http://api.jquery.com/jQuery/

mattsven
  • 22,305
  • 11
  • 68
  • 104
  • I don't know... I'm reading Simply JavaScript and what Kevin Yank says about event listeners makes me think: "And you want me to learn THIS before I use jQuery?" I feel like the Aflac commercial with Yogi Berra. – Phillip Senn Mar 27 '11 at 03:40
  • LOL. jQuery is EXTREMELY EASY to learn...you've got nothing to worry about. – mattsven Mar 27 '11 at 04:33
1

I think a good approach is to understand the syntax of JavaScript and have a basic understanding of how to manipulate the DOM, make ajax calls, etc. It's good to have an idea of what jQuery is doing for you. Getting the basics down will give you a good intuitive sense what you should do in JavaScript (calculations for example) vs jQuery (DOM manipulation for example).

When moving from JavaScript to jQuery, you will really improve your CSS selector skills. If you have strong CSS selector skills jQuery will be a snap.

Andy Gaskell
  • 31,495
  • 6
  • 74
  • 83
  • jQuery and JavaScript have not been a snap. Can I hear an amen? – Phillip Senn Mar 27 '11 at 03:38
  • I did have the "if you have strong CSS selector skills" qualifier :) – Andy Gaskell Mar 27 '11 at 03:45
  • Oh I understand css (except for float). I just have a hard time understanding how 'this' can change depending on how the function is called and things like http://bonsaiden.github.com/JavaScript-Garden/ – Phillip Senn Mar 27 '11 at 03:50
  • While jQuery'n `this` is always a reference to a DOM object. Want to jQueryify it? Use `$(this)`. The link you reference starts to get deep quickly if you're new to JS. It should make more sense after you work your way through your book. – Andy Gaskell Mar 27 '11 at 03:57
  • Thanks Andy! I will keep plugging away. – Phillip Senn Mar 27 '11 at 04:57