Cufon和Jquery Magic预览 [英] Cufon and Jquery Magic Preview
问题描述
jQuery Magic预览允许用户输入文本并使其自动更新(很像此提交字段"与下面的预览加载一起使用!).我希望用户能够输入文本,然后输入Cufon字体来接管他们编写的内容(或只是将其键入为cufon字体).
Jquery Magic preview allows a user to enter in text and have it auto update (much like this "submission field" works with the preview loading below!). I would like the user to be able to enter in the text and then the Cufon font to take over what they've written (or just have it typed in cufon font).
$(function() {
$('form.example input:text').magicpreview('mp_');
});
Cufon.replace('p#mp_trythis1');
此处的示例: http://twmorton.com/magicpreviewjquery/
推荐答案
以下是简化版本(无magicpreview):
Here is a simplified version (without magicpreview):
html部分:
<h1>Cufon Test</h1>
<input id="in" type="text">
<div id="out"><h1>Start typing ...</h1></div>
javascript部分:
The javascript part:
Cufon.replace('h1');
$('#in').keyup(function(){
$('#out').html('<h1>'+$(this).val()+'</h1>');
Cufon.replace('#out h1');
});
请参阅实时示例此处
您可以在此处中看到两个替代版本,这些版本已实现为jQuery插件.
you can see two alternative versions here implemented as jQuery plugins.
- v1在焦点丢失后的1000毫秒处更新&只有脏了
- v2在最后一次按键后1000毫秒更新一次
这篇关于Cufon和Jquery Magic预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!