JS: Failed to execute 'getComputedStyle' on 'Window': parameter is not of type 'Element'

前端 未结 6 1805
北海茫月
北海茫月 2020-12-09 14:56

In short: I am trying to understand the meaning of this TypeError: Failed to execute \'getComputedStyle\' on \'Window\': parameter 1 is not of type \'Element\' The error app

6条回答
  •  心在旅途
    2020-12-09 15:33

    I had this same error showing. When I replaced jQuery selector with normal JavaScript, the error was fixed.

    var this_id = $(this).attr('id');
    

    Replace:

    getComputedStyle( $('#'+this_id)[0], "")
    

    With:

    getComputedStyle( document.getElementById(this_id), "")
    

提交回复
热议问题