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?

jsfiddle

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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -