jQuery: How to combine two lines of code (with same target) -


i new jquery , trying combine following 2 lines of code both target same div ( $(this).closest('div.col-9').nextall('div.hiddendiv') ) , have other, similar scenarios reduce code well:

$(this).closest('div.col-9').nextall('div.hiddendiv').find('input, select, textarea').removeprop('checked').removeprop('selected').not(':button, :checkbox, :hidden, :radio, :reset, :submit').val(''); $(this).closest('div.col-9').nextall('div.hiddendiv').hide(); 

it works fine way written above combining wrong way.
i tried both following both fail:

$(this).closest('div.col-9').nextall('div.hiddendiv').find('input, select, textarea').removeprop('checked').removeprop('selected').not(':button, :checkbox, :hidden, :radio, :reset, :submit').val('').end().hide();  $(this).closest('div.col-9').nextall('div.hiddendiv').find('input, select, textarea').removeprop('checked').removeprop('selected').not(':button, :checkbox, :hidden, :radio, :reset, :submit').val('').hide(); 

can tell me doing wrong here ?

many in advance, mike

you should call $.fn.hide() method first find children , preform required operation.

$(this)     .closest('div.col-9')     .nextall('div.hiddendiv')     .hide()  //<=-----------------------   call hide method     .find('input, select, textarea')     .removeprop('checked')     .removeprop('selected')     .not(':button, :checkbox, :hidden, :radio, :reset, :submit')     .val(''); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -