我試圖通過 onclick 屬性從 html 按鈕調用 js 函數。我在哪里傳遞兩個字符串作為參數。我在參數部分中回顯了兩個 php 變量,這在邏輯上似乎是正確的,并且該函數也接受了這些參數,但沒有發生任何事情。它給我的功能不是用按鈕 onclick error 定義的。下面是代碼:腳本功能<script> function displayCommentSection(var cs, var cb) { // alert("in"); // alert(cs+" "+cb); if (document.getElementById(cs).style.display == 'block') { document.getElementById(cs).style.display = 'none'; document.getElementById(cb).innerHTML = 'comment'; } else { document.getElementById(cs).style.display = 'block'; document.getElementById(cb).innerHTML = 'cancel'; } }</script><button class="btn btn-dark" id="commentBtn<?php echo $i;?>" onclick="displayCommentSection('commentSection<?php echo $i;?>','commentBtn<?php echo $i;?>')">Comment</button>
收到此錯誤 Uncaught ReferenceError: function is not
炎炎設計
2022-01-13 15:09:29
