a developer's notes – a semi-technical web development BLOG

September 5, 2011

Get a Javascript DOM object from a jQuery object

Filed under: Javascript / JQuery — Duy Nguyen @ 1:49 pm
Tags: , , , , ,

jQuery object is a wrapper around the js DOM object. If you want to get the DOM object from the jQuery object, you should use get() method.

For example, if the jQuery object includes only one DOM object, you can use

$("div").get(0)

or

$("div")[0]

However, if you have multiple DOM objects, you can use

$("div").get()

var myvar;
myvar= $(‘#<%=selectedProductionIdsHdnVl.ClientID%>‘).get(0);
myvar.value = “b”;

same as

document.getElementById(“<%=selectedProductionIdsHdnVl.ClientID%>“).value = “B”;

This allowed me to use the ASP Hidden field and have the OnValueChanged server side event get fired.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: