我有一個計算器的代碼,現在我想添加一個%到結果,如果有一個結果。如果var不是NaN(所以它是一個數字)在jquery中添加%
當前的代碼是
var margins = num4.split(" ");
var topMarg = GetIntOrEmpty(margins[0]),
rightMarg = GetIntOrEmpty(margins[1]),
bottomMarg = GetIntOrEmpty(margins[2]),
leftMarg = GetIntOrEmpty(margins[3]);
console.log(topMarg, rightMarg, bottomMarg, leftMarg);
var shorthand1 = GetIntOrEmpty (topMarg);
shorthand1 += ' %';
如果shorthand1是空的,我希望它不添加「%」它和讓它空白。
任何想法?
您需要向我們展示GetIntOrEmpty中的內容 – Mohsen 2011-12-29 20:27:18
GetIntOrEmpty的代碼在哪裏? – 2011-12-29 20:27:24
你有什麼問題? – 2011-12-29 20:27:44