Jquery html(此处的数据)似乎“重新调整”了响应文本的大小
考虑以下代码 它是一个锚标记,id为leader module total,按下时调用一个PHP脚本,并在一个名为leader module的id内显示PHP代码中完成的回音 基本够了 但是,每次我这样做时,我都需要使用此代码段中的最后一段代码对其进行收缩 我的问题是,为什么会这样?我做错什么了吗Jquery html(此处的数据)似乎“重新调整”了响应文本的大小,jquery,response,font-size,Jquery,Response,Font Size,考虑以下代码 它是一个锚标记,id为leader module total,按下时调用一个PHP脚本,并在一个名为leader module的id内显示PHP代码中完成的回音 基本够了 但是,每次我这样做时,我都需要使用此代码段中的最后一段代码对其进行收缩 我的问题是,为什么会这样?我做错什么了吗 $('#leader-module-total').click(function() { //load an image to show while processing $('#lea
$('#leader-module-total').click(function() {
//load an image to show while processing
$('#leader-module').html( '<div class="ajaxLoader"></div>' );
//process the php script -- btw, is this valid i.e. calling it using /
//and not fully qualified with http://mydomain/page-to-be-called
$.get('/ajax-leader-module-response.php', { timeframe: 'total' },
function(data){
$('#leader-module').html( data );
}
);
//this is my question: why is this necessary???
//I need to make it smaller than it was for it to display normally.
$('#leader-module').css('font-size', '0.9333em');
return false;
});
我认为这是从父标记继承样式。请检查父元素中是否有任何字体大小样式。可能您正在注入的HTML没有一个或多个应该具有的CSS类?请参阅下面的答案。因为我的父标记有一个字体大小:1.3em,也就是说,字体大小中的EM使它与它是什么相关,所以当它刷新标记的内容时,它也使它从父标记的原始1.3em变成了1.3em。是的。是的。我不知道jQuery.html在替换父标记中的数据时重新执行了父标记。至少在所有主流浏览器中都是这样。非常感谢你的帮助。