Get value for element using jquery

Get html control[like input, select,checkbook, etc] values using jQuery they are some method as like bellow.

<!--Input Box Method 1 -->
var inputval = $('#txt_name').val();

<!--Input Box Method 2 -->
var inputval = $('#txt_name').attr("value");

<!--Input Box Method 3 this this is good method -->
var inputval = $('#txt_name').prop("value");

<!--Select Box Method 1 -->
var selectval = $('#select_val').val();

<!--Select Box Method 2 -->
var selectval = $('#select_val').attr("value");

<!--Select Box Method 3 this this is good method -->
var selectval = $('#select_val').prop("value");

Advertisements

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