我有一个推荐 slider 。通过 ajax .load() 方法从同一站点上的另一个页面提取推荐。我正在尝试将收到的推荐用引号括起来。 (例如:这是一份推荐。将是“这是一份推荐。”)。但是,我的代码无法运行。
这是应该添加引号的函数:
function quotations(){
$(this).prepend('"').append('"');
};
这是 ajax 函数(推荐从/?page=testimonials&gridID=1 .cfgThemeGridGenericContent 加载):
$(function($){
$("#slide1").load("/?page=testimonials&gridID=1 .cfgThemeGridGenericContent", function() {shorten('slide1'); quotations();})
};
html结构如下:
<div class="slides" id="slide1">
This is the testimonial text.
</div>
您看到的 Short() 函数只是一个确保推荐不会太长的函数。我已经确认它有效。如果我需要添加它,请告诉我。
为什么我的推荐没有被引用?
最佳答案
只需使用CSS:
div.slides::before,
div.slides::after {
content: '"';
}
至于“为什么它不起作用”我怀疑这可能取决于 quotations() 中的
函数。$(this)
是什么
关于javascript - jQuery - 如何在引号中包围 Ajax 加载的元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27007699/