我正在编写一个代码来添加两个数字并在另一页上显示结果。但我没有得到想要的输出。
addbtn=button id add=result page id calc=starting page 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);
});
});