Skip to content

Instantly share code, notes, and snippets.

@niwaringo
Created January 26, 2012 15:54
Show Gist options
  • Save niwaringo/1683438 to your computer and use it in GitHub Desktop.
Save niwaringo/1683438 to your computer and use it in GitHub Desktop.
jQuery Plugin fhconvert old ver
(function($) {
$.fn.fhconvert = function(type, options) {
var settings = $.extend({
'jaCode':true,
'space':true,
'convSet':'object'
}, options);
$(this).each(function() {
var $this = $(this);
var convertText = FHConvert[type]($this.val(), settings);
$this.val(convertText);
});
return this;
};
}(jQuery));
フォーカスが外れると全角になる。
<input id="zenkaku" type="text" />
<br />
フォーカスが外れると半角になる。
<input id="hankaku" type="text" />
<br />
フォーカスが外れるとカナになる。
<input id="kana" type="text" />
<script type="text/javascript">
$(function() {
$('#zenkaku').blur(function() {
$(this).fhconvert('htof');
});
$('#hankaku').blur(function() {
$(this).fhconvert('ftoh');
});
$('#kana').blur(function() {
$(this).fhconvert('hgtokk');
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment