Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Como posso acionar a classe largeFont da função fontSize dentro da função abaixo?
jQuery(function ($) {
$(document).bind('keydown', 'Alt+d', function() {
????????
});
});
<div id="font-control">
<span><a href="javascript:void(0);" class="largeFont">aumentar fonte</a></span>
<span><a href="javascript:void(0);" class="smallFont">diminuir fonte</a></span>
</div>
Obrigado!!
Não rolou, deixe eu explicar melhor: No site eu tenho link que ao ser acionado aumenta a fonte dos textos, descrito no post anterior.
Hoje eu consigo através do teclado posicionar o topo, o conteúdo ou rodapé.
Eu gostaria que ao acionar um atalho no teclado ele executasse a ação aumentar fonte.
A função que faz isso hoje é essa:
function fontSize(container, target, minSize, defSize, maxSize) {
//Read cookie & sets the fontsize
if ($.cookie != undefined) {
var cookie = target.replace(/[#. ]/g,'');
var value = $.cookie(cookie);
if (value !=null) {
$(target).css('font-size', parseInt(value));
}
}
//on clicking small font button, font size is decreased by 1px
$(container + " .smallFont").click(function(){
curSize = parseInt($(target).css("font-size"));
newSize = curSize - 1;
if (newSize >= minSize) {
$(target).css('font-size', newSize);
}
if (newSize <= minSize) {
$(container + " .smallFont").addClass("sdisabled");
}
if (newSize < maxSize) {
$(container + " .largeFont").removeClass("ldisabled");
}
updatefontCookie(target, newSize); //sets the cookie
});
//on clicking default font size button, font size is reset
$(container + " .defaultFont").click(function(){
$(target).css('font-size', defSize);
$(container + " .smallFont").removeClass("sdisabled");
$(container + " .largeFont").removeClass("ldisabled");
updatefontCookie(target, defSize);
});
//on clicking large font size button, font size is incremented by 1 to the maximum limit
$(container + " .largeFont").click(function(){
curSize = parseInt($(target).css("font-size"));
newSize = curSize + 1;
if (newSize <= maxSize) {
$(target).css('font-size', newSize);
}
if (newSize > minSize) {
$(container + " .smallFont").removeClass("sdisabled");
}
if (newSize >= maxSize) {
$(container + " .largeFont").addClass("ldisabled");
}
updatefontCookie(target, newSize);
});
function updatefontCookie(target, size) { //Private function for setting cookie
if ($.cookie != undefined) { //If cookie plugin available, set a cookie
var cookie = target.replace(/[#. ]/g,'');
$.cookie(cookie, size);
}
}
}
Deu pra entender? Abraço e o Obrigado!
adicionar a classe? você quer dizer colocar ela no elemento?
seria isso?