I have a select dropdown from which once you select an option and click a button it adds it to a div to display what you chose. You can keep adding options from the select dropdown.
I need the div which is holding these appended values to output what it currently has in another div. Here is my code.
<div class="col-12 col-md-7">
<span>Select the fixture type:*</span>
<select id="fixture-type">
<option>Select1</option>
<option>Select2</option>
<option>Select3</option>
</select>
<button class="btn-primary" type="button" id="add-fixture-btn">+ ADD FEATURE</button>
</div>
<div class="col-12 col-md-5">
<span>Your Fixtures</span>
<div class="append-list">
<!--Append selection box items here-->
</div>
</div>
Then this JQuery appends the selected options to the append-list div.
$("#add-fixture-btn").click(function() {
$(".append-list").append('<li style="list-style: none;">' + $('#fixture-type').val() + '<div class="delete"></div>' + '</li>');
});
This part works wonderfully. Now I need append-list div to display its values in another div:
<div class="col-12 spacing">
<h5><strong>Fixture Types</strong></h5><div id="input21"></div>
</div>
And I am using this JQuery to try to show the options:
$("#input21").text($('.append-list'));
But instead of displaying the values from the selected options, it shows me [object Object]. What does this mean? and why is it not printing the values?
I have tried to do $("#input21").text($('.append-list').val()); and that displays nothing not even the [object Object] part. I also tried $("#input21").clone($('.append-list')); and no luck. Also did appendTo(). Did not work.
Thanks!
lielements can only be children of anol,ul, ormenu– not adiv.$('.append-list')returns a jQuery object containing a result stack of the elements that match that class. If you try to toString() an object, which I'm almost certaintext()will do, it will out put [Object object] if it doesn't know how else to turn it into a string.text($('.append-list').html())or you may want to use html instead of text on the outside so it doesn't show the html as text in the secondary element. But you should also take note of what Rick pointed out. Ref. html.spec.whatwg.org/multipage/…