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:
Comments
Post a Comment