javascript - Need text in input to not display user input once sent -
here jquery, have working once row added user input in inputs still there , not cleared. how fix this?
// removing menu rows $('.menu-items').on('click', '.delete', function(){ $(this).closest('.menu-row').remove(); }); // html var menu_row_template = '<div class="menu-row"><span class="item-description">$description</span><div class="control-items"><span class="item-price">$price</span><span class="delete">x</span></div></div>' // adding menu rows $('.menu-category').on('click', 'button', function(){ var $row = $(this).closest('.add-item'); var name = $row.find('input').first().val(); var price = $row.find('input').last().val(); var newrowhtml = menu_row_template.replace('$description', name).replace('$price', price); var $newrow = $(newrowhtml); var $lastmenurow = $row.closest('.menu-category').find('.menu-row').last(); $newrow.insertafter($lastmenurow); });
sorry poor explaining skills.
clear name , price after values...
... var name = $row.find('input').first().val(); var price = $row.find('input').last().val(); $row.find('input').first().val(''); $row.find('input').last().val(''); ...
Comments
Post a Comment