我创建了一个脚本,它应该增加或减小文本的大小(如下所示),但问题是当我单击其中一个图像并传递参数时,文本的大小保持不变menos
<script>
function increase_text(size,mode) {
var size_ini=16;
var size_max=20;
var size_min=16;
if (mode=="mas")
{
var size_increase = size_ini++;
alert("ok"+size_increase);
if (size_increase<20)
{
$(".content").css("font-size",""+size_increase+"px");
}
else
{
$(".content").css("font-size",""+size_max+"px");
}
}
if (mode=="menos")
{
var size_increase = size_ini--;
if (size_increase>=20 || size_increase>=size_min)
{
$(".content").css("font-size",""+size_increase+"px");
}
else
{
$(".content").css("font-size",""+size_min+"px");
}
}
}
</script>
标记
<div style="position:relative;width:100%;border:0px solid;height:40px;">
<img src="http://127.0.0.1/tfw_end/wp-content/themes/thefactoyweb/images/text_decrease.png" onclick="increase_text('1','menos');" style="display:block;float:right;cursor:pointer;cursor:hand;" alt="Aumentar Texto" title="Aumentar Texto">
<img src="http://127.0.0.1/tfw_end/wp-content/themes/thefactoyweb/images/text_increase.png" onclick="increase_text('1','mas');" style="display:block;float:right;cursor:pointer;cursor:hand;" alt="Reducir Texto" title="Reducir Texto"></div>
问候