我是新来的JavaScript,我想打印网页上我的变量,而不是使用<span>
和innerHTML
JavaScript来在屏幕上打印
var pProductCode = $('[name=pProductCode]').val();
$('input[id*="_IP/PA_N_"]').each(function(i){
ipPAAmt += Number(convertToNumber($(this).val()));
});
我怎么能这样做?
我是新来的JavaScript,我想打印网页上我的变量,而不是使用<span>
和innerHTML
JavaScript来在屏幕上打印
var pProductCode = $('[name=pProductCode]').val();
$('input[id*="_IP/PA_N_"]').each(function(i){
ipPAAmt += Number(convertToNumber($(this).val()));
});
我怎么能这样做?
有适用于您的情况,在更详细的解答: How to display javascript variables in a html page without document.write
基本上你想创建一个HTML元素,然后用你的变量替换的内容。
避免只是链接到其他答案。你已经确定了一个重复的问题,它应该被标记为这样。 http://stackoverflow.com/questions/9689109/how-to-display-javascript-variables-in-a-html-page-without-document-write – Scott
谢谢,我试图找出如何但没有代表在当时做它。我现在这样做,所以我现在要确保这样做。 – user3098015
$('#yourDivID').html(ipPAAmt);
要打印的地方?在控制台意味着使用'console.log(ipPAAmt)'警报手段使用'alert(ipPAAmt)'在html意味着使用'$('#yourElementID')。html(ipPAAmt);' –
请解释您的问题... – ArchFever
重复的http://stackoverflow.com/questions/9689109/how-to-display-javascript-variables-in-a-html-page-without-document-write – Scott