Get real width of elements with jQuery

前端 未结 6 1977
Happy的楠姐
Happy的楠姐 2021-02-12 16:48

I am writing a validator for \"visual correctness\" of html files. The goal is to detect too wide elements.

Here is a demo of my problem.

The do

6条回答
  •  孤独总比滥情好
    2021-02-12 17:33

    scrollWidth will do it:

    $("#two").get()[0].scrollWidth or getElementById("two").scrollWidth

    this outputs 212px, the real width you are looking for.

提交回复
热议问题