0
Ich habe eine Liste, die auswählbar ist. Ich möchte zum Beispiel, wenn ich 3 Elemente auf dieser Liste auswählen, dann klicken Sie auf die Schaltfläche Bestätigen, um die li
Elemente zu einem Array hinzuzufügen. Und wenn ich andere Elemente auswähle, möchte ich sie auch zu diesem Array hinzufügen.Ich möchte die li-Elemente in ein Array setzen
$(document).ready(function() {
$("#add").on("click", function(e) {
$("#list").append("<li>" + $("#prenume").val() + " " + $("#nume").val() + "</li>");
return false;
})
$(function() {
$("#list").selectable();
});
$("#confirm").on("click", function() {
});
});
#feedback {
font-size: 1.4em;
}
#list .ui-selecting {
background: #FECA40;
}
#list .ui-selected {
background: #F39814;
color: white;
}
#list {
list-style-type: none;
margin: 0;
padding: 0;
width: 20%;
}
#list li {
margin: 3px;
padding: 0.4em;
font-size: 1.4em;
height: 18px;
}
li:hover {
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
Prenume
<input type="text" id="prenume"></input>
Nume
<input type="text" id="nume"></input>
<select>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<button id="add">Add</button>
</form>
<ul id="list">
</ul>
<ul id="confirmed_list">
</ul>
<button id="confirm">Confirm</button>
Der Code funktioniert nicht, weil der jquery-ui. –