如何将play_ID传递给函数toggleSound()?
onclick=\"javascript:var play_ID=$id;toggleSound();\"
<script type=\"text/javascript\">
<script type=\"text/javascript\">
function toggleSound() {
audioElem = document.getElementById(\"audio". $row["ID"]."\");
if (audioElem.paused)
audioElem.play();
else
audioElem.pause();
}
</script>
答案 0 :(得分:2)
如果我理解你的问题是正确的,你想将$ Id变量传递给你的函数吗?
onclick=\"javascript:toggleSound($id);\"
<script type=\"text/javascript\">
<script type=\"text/javascript\">
function toggleSound(inVar) {
//inVar is equal to the variable you want to pass into the function.
audioElem = document.getElementById(inVar);
if (audioElem.paused)
audioElem.play();
else
audioElem.pause();
}
</script>