[英]JS: calling a function from another JS file
我想返回一些在 translacao.js 中修改過的translacao.js
。 我想回到這個數值並執行dda.js
由translacao.js
文件
$(document).on('click', '#trans', function () {
var tx = parseInt($('#tx').val());
var ty = parseInt($('#ty').val());
translation(tx, ty);
});
function translation(tx, ty) {
x1 = x1 + tx;
y1 = y1 + ty;
x2 = x2 + tx;
y2 = y2 + ty;
return dda(x1,y1,x2,y2);
}
我建議您始終將 JavaScript 代碼放在document.onload
事件中。 它總是一個很好的用法:
document.onload = function(){
// your code
};
在 jQuery 中,您有更好的選擇:
$(document).ready(function() {
// your code
});
這樣您的代碼將始終在文檔完全加載時執行,因此在加載所有 js 文件時。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.