I have the following html code
<input codprueba="Prueba1" type="checkbox" title="Observaciones Prueba1">
<input codprueba="Prueba2" type="checkbox" title="Observaciones Prueba2">
<input codprueba="Prueba3" type="checkbox" title="Observaciones Prueba3">
And through JQuery, I want to concatenate in a variable separated by "|"
, for example, the value they have in the attribute codprueba
.
That is, if the first and third checkboxes are checked back
var cadena = 'Prueba1|Prueba2'
What I have come to is the following code, but I do not know how to continue.
var cadena = $("input[type=checkbox]").prop("checked", true).attr("codprueba");
alert(cadena);
var cadena = $("input[type=checkbox]").prop("checked", true).attr("codprueba");
alert(cadena);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input codprueba="Prueba1" type="checkbox" title="Observaciones Prueba1">
<input codprueba="Prueba2" type="checkbox" title="Observaciones Prueba2">
<input codprueba="Prueba3" type="checkbox" title="Observaciones Prueba3">