2 つの数値を加算して結果を別のページに表示するコードを書いています。しかし、目的の出力が得られません。
addbtn=ボタンID add=結果ページID calc=開始ページID ....ここに私のコードがあります:
// Bind to 'page init' event for our data page
$(document).delegate('#calc', 'pageinit', function() {
// Do some processing when the button with id 'addbtn' is clicked ( or tapped )
$('#addbtn').click(function() {
// Read the values
var num1 = $("#num1").val(), num2 = $("#num2").val();
var add = parseInt(num1) + parseInt(num2) ;
$add = $('#add');
// Clear the value if value isn't proper
if (add == '0.000' || add == 'Infinity' || add == 'Na N') {
add = '';
}
// Get to the DOM node that has the actual text
while ($add.children().length) {
$add = $add.children().first();
}
// Set it to the calculated value
$("#add").text(add);
});
});