Following up on my question about jQuery.get() I was wondering if there is a list of DOM properties and methods that aren't available in jQuery that can only be accessible if you were working with the raw DOM object (i.e. $("#someID").get().scrollHeight; )
I could be wrong, but I think you can access any properties via the attr method.
I don't know of a compiled list of DOM operations/properties that are NOT available in jQuery (and a quick google search didn't turn anything up), but if you go to http://api.jquery.com/ you can see the entire API, and even download it as an Adobe AIR app in case you don't have internet when you need it.
Every attribute of every element is accessible through the attr()
function. If you could do a document.getElementById()
on that element and then access a property, you can also do it using the attr()
function. However, some properties are accessed more easily in other ways when using jquery. For example, to see if an element is hidden or visible, you could do:
var isVisible=$("#el").is(":visible");
instead of using the attr()
method. Similarly, you can find the selectedIndex
of dropdowns and the text of the selected option, in easier ways than using the attr()
method. This pdf outlines some of these easier approaches.
To access a css property, you are better off doing:
var fontWeight=$("#el").css("fontWeight");
rather than using get()
or attr()
. You can also set the css properties in this way, e.g:
$("#el").css("fontWeight","bold");
No. JQuery is just JavaScript. If you can do it in JavaScript, you can do it in jQuery. Some properties and methods are overwritten in the context of a jQuery object and that's where you would want to us the get() method--to 'get' (i.e. access) the standard property/method.
That's really as complicated as it is.
I haven't encountered a list but if one existed it would probably be quite lengthy. In addition to browser-specific (proprietary) properties there's a bunch of other less useful properties and methods not currently abstracted by jQuery. But then, I don't really see this as a problem, or even a valid point of discussion because jQuery IS JavaScript; if you need access to something beyond what jQuery provides then you can use get()
or access a specified element within one of your "jQuery collections" like an array:
jQuery(elem)[0].someDOMProperty;
Plus jQuery provides absolutely no support for non-element nodes within the DOM. If, for whatever reason, you need direct access to comment nodes, text nodes etc. then you'll need to use the "raw" DOM.
No Kyle, you're misunderstanding his question. We all understand jQuery is just a JS library.
The question is, when working with a jQuery collection object, such as one returned via this statement
var obj = jQuery('div');
What properties aren't available through this object that are available in a typical DOMElement.
And that list is almost endless, you certainly can't do something like
if(obj.nodeType == 3)... the jQuery object simply doesn't have the nodeType property, nor almost all DOM properties.
My best suggestion would be to inspect these objects yourself via firebug and just become familiar with both.