私は独自のjqueryプラグインの構築を学ぼうとしています。簡単な例ですが、実行中にエラーが発生します。
ローン計算機
エラーに関して私を助けることができます」
期待されるオブジェクト
index.htmlの私のjavascriptは次のようになります...
$(function(){
$('#btn').click(function() {
var roi=getie(); // ROI - rate of interest - value of i receved from function getie()
$("#i").val(roi); // input type 'text ' to display Interest (i) value
});
});
およびカスタム関数のプラグインコード
getie()
別々にこのようになります
calculate.jsファイル
コード:
(function($){
//Attach this new method to jQuery
$.fn.extend({
//This is where you write your plugin's name
getie: function() {
//Iterate over the current set of matched elements
return this.each(function() {
var i=20;
return i;
});
}
});
})(jQuery);
私はこので他のjsファイルとしてjquery-1.7.2.min.jsとquery-ui-1.8.20.custom.min.jsを使用しています。