Why can I not retrieve CSS background property of DOM element

前端 未结 1 1865
孤街浪徒
孤街浪徒 2021-01-27 12:04

I am trying to set the css background property of an element to a variable.

But when I log my var. to the console, it is an empty string.

Can anyone see what I

1条回答
  •  一生所求
    2021-01-27 12:59

    background is a shorthand property. From http://api.jquery.com/css/:

    Retrieval of shorthand CSS properties (e.g., margin, background, border), although functional with some browsers, is not guaranteed.

    You may need to check background-color, background-image, etc.

    0 讨论(0)
提交回复
热议问题