提问人:Jane Lim 提问时间:8/18/2023 最后编辑:Some programmer dudeJane Lim 更新时间:8/18/2023 访问量:38
在 html [closed] 中插入后无法显示变量
Variable failed to be shown after inserting in html [closed]
问:
const jQuery = jQuery;
const optNumber = jQuery('.notificationCenter__list li').length;
const html2 = `
<span class="optHeaderMdSm__notification__unread">(jQuery('.notificationCenter__list li').length)</span>
`;
jQuery('.headerLg__notification .link__icon').after(html).remove('.headerLg__notification .link__icon');
答:
-2赞
Sona Rijesh
8/18/2023
#1
const optNumber = jQuery('.notificationCenter__list li').length;
const html2 = `
<span class="optHeaderMdSm__notification__unread">(${optNumber})</span>
`;
jQuery('.headerLg__notification .link__icon').after(html2);
// Remove the link__icon element
jQuery('.headerLg__notification .link__icon').remove();
在使用 jQuery 函数之前,请确保已将 jQuery 库正确包含在 HTML 页面中。
评论
"jQuery('.notificationCenter__list li').length"
${optNumber }
const html2 = `<span class="optHeaderMdSm__notification__unread">${optNumber}</span>`;