I need to enhance the functionality of clicking on multiple objects in order to display all titles at once within the header.
Currently, only one title is shown each time an object is clicked.
Therefore, when clicking on items 1, 2, and 3, I expect to see all respective titles displayed simultaneously.
$("document").ready(function() {
$(".ui-widget-content").on("click", function() {
$("#select-result").text($(this).attr('text'));
});
});
#feedback {
font-size: 1.4em;
}
#selectable .ui-selecting {
background: #FECA40;
}
#selectable .ui-selected {
background: #F39814;
color: white;
}
#selectable {
list-style-type: none;
margin: 0;
padding: 0;
width: 450px;
}
#selectable li {
margin: 10px;
padding: 1px;
float: left;
width: 100px;
height: 80px;
font-size: 4em;
text-align: center;
}
.wrapper {
display: flex;
margin: auto;
justify-content: center;
align-items: center;
}
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<div class="wrapper">
<div>
<p id="feedback">
<span>You've selected:</span> <span id="select-result">none</span>.
</p>
<ol id="selectable">
<li class="ui-widget-content" text="car">1</li>
<li class="ui-widget-content" text="truck">2</li>
<li class="ui-widget-content" text="physics">3</li>
<li class="ui-widget-content" text="maths">4</li>
<li class="ui-widget-content" text="home automation">5</li>
<li class="ui-widget-content" text="car6">6</li>
<li class="ui-widget-content" text="car7">7</li>
<li class="ui-widget-content" text="car8">8</li>
<li class="ui-widget-content" text="car9">9</li>
<li class="ui-widget-content" text="car10">10</li>
<li class="ui-widget-content" text="car11">11</li>
<li class="ui-widget-content" text="car12">12</li>
</ol>
</div>
</div>