$(document).ready(function () { $("#myButton").click(function () { var text = ""; $(":Checked").each(function () { text = text + " " + $(this).val(); }); var spanText = $("#checkedSpan").html(); if (spanText != null) { $("#checkedSpan").innerHTML = " "; } $("#checkedSpan").html("You selected: " + text); }); });
<html> <head> <title>checked Selector</title> </head> <body> <input type="checkbox" name="BE" value="BE">BE <input type="checkbox" name="ME" value="ME">ME <input type="checkbox" name="MS" value="MS">MS <input type="checkbox" name="MCA" value="MCA">MCA <button id="myButton">Click</button><br> <span id="checkedSpan"></span> </body> </html>