Is it possible to get Cufon to work on a button?

Tom Harvey picture Tom Harvey · Aug 22, 2009 · Viewed 10.5k times · Source

So right now I'm bashing my head - at the moment we use an element for a button to give it our own custom font, fine - this works, but as we're using Cufon on the rest of the site, we're wondering if it's possible to get Cufon working on a button.

So far I've changed the button to an and using standard css styles on an 'input' or 'input[type="submit"]' element work fine - but I've tried both of these in cufon to no avail.

This is a button - so as Cufon generates images, this should work, but maybe I'm doing it wrong - can anyone help?

Answer

Paul Welsh picture Paul Welsh · Jul 14, 2010
$('.input-button').each(function(){
    $(this).hide().after('<span class="input-button">').next('span.input-button').text($(this).val()).click(function(){
        $(this).prev('input.input-button').click();
    });
});

I used the above code to copy my inputs value into a span, which allows me to use cufon. It works great and still falls back to the 'submit' input with javascript disabled.