Jquery store string and put it out elsewhere when checkbox is checked -


looking here. have create price check calculator. 2 things need done:

  1. if checkboxes different values checked overallprice has shown somewhere.
  2. i need summary of selected items. need put selected items beneath overallprice.

i managed point 1 work. im struggling point 2. have no clue how put checked items elsewhere.

heres how far ive got:

$(document).ready(function() {  $('input[type="checkbox"]').click(function() {    var total = 0;    //var item = [];    var $parent = $(this).closest('ul');    $parent.find('input:checked').each(function() {       total += parseint($(this).val());       //item.text();    });    $parent.find('span[class^=total]').html(total + ' €');     var overallprice = 0;    $('span[class^=total]').each(function() {      overallprice += parseint($(this).html().replace(' €',''));    });    $('.overallprice').html(overallprice)    //$('.overallprice').append(item);    }); }); 

and better understanding jsfiddle

i'd grateful help. alot!

you need loop through checked boxes , label values:

  1. get checked check boxes , loop through them.
  2. for each one, label's text content that's next , append it.

code

// checked check boxes $("input:checked").each(function () {     // each one, label's text content that's next , append it.     $('.overallprice').append("<br>" + $(this).next("label").text()); }); 

fiddle: https://jsfiddle.net/truvrurc/


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -