我的代码有效,但我必须使用两个按钮才能使其工作,但我想将 2 个功能组合到 1 个按钮中,但它不起作用我什至尝试过这个
onclick="printResult('result_container'); deleteEmptyCol();"
<form>
<input type="submit" value="Save" class="md-close" />
</form>
<input type='button' value='Delete Empty Fields' onclick="deleteEmptyCol()" />
<input type='button' id='printResult' value='Print Result' onclick="printResult('result_container')" />
功能
function printResult(result_container) {
var printContents = document.getElementById(result_container).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
window.focus();
document.body.innerHTML = originalContents;
}
function deleteEmptyCol() {
if(document.getElementById('fec_col').value === '') {
$("#col").fadeOut();
}
if(document.getElementById('fec_con').value === '') {
$("#con").fadeOut();
}
if(document.getElementById('fec_blood').value === '') {
$("#blood").fadeOut();
}
}