如何添加2个onclick功能

时间:2017-01-17 20:35:42

标签: javascript html button onclick

Parameter:Tabslan2%24ctl02%24gvTasks2%24ctl00%24ctl06%24rptrComments%24ctl01%24FC%24hdnUserName
Value: at1+Tra+AN%2C+LPN%2C+MD%2C+RN%2C+BS%2C+BA+%28Ph

如何在每次onclick事件之前添加一串文本。 例如,第二个按钮的输出是" 6"虽然我希望它是"列表中的项目数量是:6"

2 个答案:

答案 0 :(得分:0)

你可以连接字符串:

<button type = "button" onclick = "document.getElementById('prod3').innerHTML = 'the number of items in the list is: ' + products.length;">Count the number of items in the list!</button>

答案 1 :(得分:0)

你好把文字放在&#39; text&#39;并在添加+。
像这样:

<button type = "button" onclick = "document.getElementById('prod3').innerHTML = 'the number of items in the list is: ' + products.length;">