我有一個HTA,其中必須更新innerHTML
與類driveLetter
的一組元素。在我這樣做之前,我顯然必須獲取這個類的所有元素的數組。嘗試獲取具有特定類的所有元素時出錯
我試過這樣做與JS,但是我通過錯誤告訴兩種方法不支持(測試IE9和IE11)。在HTML文件中使用這些函數是可行的,但這是一個HTA。
對象不支持屬性或方法 'getElementsByClassName方法'
對象不支持屬性或方法 'querySelectorAll'
-
var driveLetterInstances = document.getElementsByClassName("driveLetter");
var driveLetterInstances = document.querySelectorAll(".driveLetter");
通過上面的行中產生的錯誤我沒有特別的必須使用JS,並且可以開放使用VBS來執行這個功能,但我不知道如何開始使用(或者甚至是可能的)。
getElementsByClassName is supported IE9 + https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName – AmmarCSE
您可以在小提琴中複製問題嗎? – AmmarCSE
你可以使用'getElementByClassName'或'querySelectorAll'來顯示你更新'innerHTML'的嘗試,並且你是否使用for循環遍歷元素數組? – NewToJS