好的,所以我有这个加载外部文件的脚本,但现在我想修改它,以便它加载内部隐藏的内容。有人可以帮我解决这个问题吗?此脚本有两个部分:1)当有人单击带有"o-links"类的某个链接时,它会滑动打开,显示请求的内容。然后是另一个链接(o-close-link),用于关闭先前的幻灯片打开显示区域。
我也一直在尝试添加一个 gif 加载器,但没有运气。我只是真的希望这能工作,但我尝试无济于事。请帮我解决这个问题,任何人。请!
$(document).ready(function() {
$('.o-links').click(function() {
var href = $(this).attr('href');
$.get(href, function(data){
$('.reserved-area').hide('fast');
$('.reserved-area').html(data).slideDown('slow');
});
return false;
});
$('.o-close-link').click(function() {
var href = $(this).attr('href');
$.get(href, function(data){
$('.reserved-area').hide('fast');
$('.reserved-area').html(data).slideDown('slow');
});
return false;
});
});
使用此解决方案,您可以通过在腐蚀链接的 href 中引用隐藏元素的 id 来将隐藏元素的内容加载到您的.reserved-area
中:
$('.o-links').click(function() {
// href has to be the id of the hidden content element
var href = $(this).attr('href');
$('.reserved-area')
.hide('fast')
.html($(href).html())
.slideDown('slow');
return false;
});