javascript - How to get value of 'this' inputbox? -


i writing web application user clicks on div, holding input text box predefined text in it. when user clicks on div code printed in separate text box. trying write function grabs value of the clicked on div's text input. have working clicking on input box using $(this).val(); want click on div , gets value of (this)('input[type=text].provided_code').val();

is there way text input inside div? there 20 div's on page 20 inputs in each div, , each have same class name etc.

yes can specify selector context:

by default, selectors perform searches within dom starting @ document root. however, alternate context can given search using optional second parameter $() function

documentation: http://api.jquery.com/jquery/#jquery1

so code this:

$('input[type=text].provided_code', this).val() 

performance:

http://jsperf.com/jquery-find-vs-context-sel/38


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -