Over a million developers have joined DZone.

Easily Get A Single Element With JQuery

DZone's Guide to

Easily Get A Single Element With JQuery

Free Resource
While jQuery is a great help, a lot of times I just need to grab a single element. It's a real PITA to have to write $('#mydiv').get(0) all the time, so here's a solution:

$.first = function(a, b) {return $(a, b).get(0)};

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}