RedWolves
RedWolves

Reputation: 10395

DOM properties/methods that aren't available in jQuery?

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; )

Upvotes: 4

Views: 713

Answers (5)

James
James

Reputation: 112000

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.

Upvotes: 4

Ali
Ali

Reputation: 267267

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");

Upvotes: 0

KyleFarris
KyleFarris

Reputation: 17548

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.

Upvotes: 0

Scott M.
Scott M.

Reputation: 7347

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.

Upvotes: 0

Matt
Matt

Reputation: 2230

I could be wrong, but I think you can access any properties via the attr method.

Upvotes: -1

Related Questions