Displaying form inputs using jquery -


i want write jquery code show form inputs after checkbox checked. how have formated form inputs. best way of doing this?

    echo '<li class="checkbox_item">'. form_label('number of bedrooms','bedrooms'). form_checkbox('bedrooms','yes'). form_error('bedrooms').'</li>';     echo '<li class="input_item" id=no_rooms>'. form_label('number of bedrooms','bedrooms'). form_input('bedrooms'). form_error('bedrooms').'</li>';      echo '<li class="checkbox_item">'. form_label('number of bathfooms','bathrooms'). form_checkbox('bathrooms'). form_error('bathrooms').'</li>';     echo '<li class="input_item">'. form_label('number of bathfooms','bathrooms'). form_input('bathrooms'). form_error('bathrooms').'</li>'; 

you do:

//hide inputs $('.input_item').hide()  //when checkbox ticked, hide/unihde next li  $('.checkbox_item input').click(function(){     $(this).closest('li').next('.input_item').toggle($(this).is(':checked')); }); 

working fiddle http://jsfiddle.net/ttyx8/1/

edit (i added selector next code better)


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -