html实现div打印,如何在html div的中间打印/附加从按钮单击的值?
在帶有onclick功能(example here)的導(dǎo)航菜單上,顯示div標(biāo)簽內(nèi)容我想傳遞一個(gè)附加值來加載特定內(nèi)容。這是當(dāng)前的代碼:如何在html div的中間打印/附加從按鈕單擊的值?
- London
- Paris
- Tokyo
London
London is the city of England.
Paris
Paris is the capital of .
Tokyo
Tokyo is the capital of .
這是JavaScript:
function openCity(evt, cityName, ThirdValue) {
// Declare all variables
var i, tabcontent, tablinks;
// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
// Show the current tab, and add an "active" class to the link that opened the tab
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
alert(ThirdValue);
}
我不能到div內(nèi)得到第三個(gè)變量。我能夠看到它與alert(ThirdValue);,但使用我不能夠在html中添加它。
我需要在html中添加此值。我該如何在html中打印/追加這個(gè)值?
總結(jié)
以上是生活随笔為你收集整理的html实现div打印,如何在html div的中间打印/附加从按钮单击的值?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html 根作用域,AngularJS入
- 下一篇: 计算机文化基础在线作业答案,中国石油大学