我有一个函数,它使用缓存元素(el)更改字体大小2 divs。当函数执行时,我需要确定字体不是太小或太大,取决于它是哪个div(tagCommon
或tagLatin
)。那么如何在函数中确定哪个元素通过el
传递给它?jQuery缓存元素
我想我可能已经在考虑这个或者做错了,它有点像我黑客它在......并且通常当它觉得有什么不对劲的时候。
var cb = $('#tagCommon');
var lb = $('#tagLatin');
changeFontSize(cb,1,'up');
function changeFontSize(el,amount,UporDown){
var size = parseFloat($(el).css("font-size").replace(/px/, ""));
// do some stuff here
// ????????
if(el == $('#tagCommon')) //check font size and alert if too small
if(el == $('#tagLatin')) //check font size and alert if too small
}
谢谢你的时间。
托德