javascript - show multiple selected span values in jquery using comma -
i've posted full code on jsfiddle. i'm trying show user selected seats here. if user selected 2 bs result should bs-2. again if user selected 4 fc result should added old 1 bs-2, fc-4.
but, i've tried here. show value of span element if selected 1 replaces previous one. how add comma , show multiple selected span values in jquery?
jquery
$(".text").click(function(){ $(this).toggleclass('selected'); var data = $(this).text(); $('.returndata').text(data); })
try
var $texts = $(".text").click(function () { $(this).toggleclass('selected'); var selected = $texts.filter('.selected').map(function () { return $.trim($(this).text()) }).get() $('.returndata').text(selected.join()); })
demo: fiddle
Comments
Post a Comment