【发布时间】:2019-03-20 02:45:26
【问题描述】:
从 div 中获取文本值并通过 jquery 插入到标签中。得到未捕获的错误:语法错误,无法识别的表达式:错误。
硬编码值可以正常工作。
JS:
$('.select-destination').on('click', function () {
let getDiscovery = $('.findTxt').text();
//it works fine $('<h5>Find other DISCOVERY hotels</h5>').insertBefore($('.group-result.gha-group:first'));
$("'<h5>'+getDiscovery+'</h5>'").insertBefore($('.group-result:first'));
});
HTML:
<div class="findTxt hidden">Find other Hotels</div>
【问题讨论】: