0
我想將keyup事件上的charcode傳遞給jquery插件。實際上直到現在我正在使用jquery函數,我的工作就是這樣。 我的HTML如何將charcode傳遞給jquery插件
<body>
<SCRIPT type="text/javascript" src="working.js"></SCRIPT>
<textarea name="source" id="src1" cols="150" rows="20" onkeyup="showRelated(event)"></textarea>
</body>
我working.js
function showRelated(e) {
var unicode = e.keyCode ? e.keyCode : e.charCode;
var str = $('#src1').val();
var spaceCheck=32;
var checkEnter=13;
if (unicode == spaceCheck || unicode==checkEnter) {
{
//my code goes here
}
}
現在我需要使用jQuery做plugin.So我的H1M1將
<head>
<script type="text/javascript" src="jquery.requireplugin.js"></script>
</head>
<body>
<textarea name="source" id="src1" cols="150" rows="20"></textarea></td>
<script type="text/javascript">
$("#src1").keyup(function() {
$('#src1').pluginmethod();
});
</script>
</body>
我jquery.requireplugin.js
(function($) {
$.fn.pluginmethod = function() {
this.each(function() {
var $str = $('#src1');
var som= $str.val();
//here i need to use charcode
});
};
})(jQuery);
現在我想知道如何將charcode傳遞給插件,以便我可以在插件中像使用workimg.js一樣使用它?