You try to access an element by accessing a string that holds the name
I think you meant to do this
$(function() {
const elements = [
$('<div class="fruit apples">Appels 1</div>'),
$('<div class="fruit oranges">Oranges 2</div>')
]
const random_element = elements[Math.floor(Math.random() * elements.length)]
$('.element-placeholder').replaceWith(random_element);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="element-placeholder"></div>
<!--This should be one of the .fruit divs instead of the text "pane_2"-->
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…