To fetch the value of a css property of a given element using jQuery
, we can use the function .css().
//Aqui retorna o valor do background-image
$('#id').css('background-image');
//Enquanto aqui o background-image vai receber o valor 'none'
$('#id').css('background-image', 'none');
Now, if you can’t or don’t want to use jQuery, there is a way to do this with Javascript only.
var element, style, backgroundimage;
element = document.getElementById('id');
style = window.getComputedStyle(element);
backgroundimage = style.getPropertyValue('background-image');
Source: Soen: Get a CSS value with Javascript
@EDIT
I didn’t realize you were using a WebBrowser
, so try to access the attribute Style
of the element returned by GetElementById
. Example:
var obj = webBrowser.Document.GetElementById("senderscore").Style
Ai using this property you can search for the background-image
within the String
.
Source: MSDN Htmlelement.Style Property
Have you tried harvesting there instead of Getattribute, Addclass ? And do the class in css and declare it directly in div.
– Érik Thiago
I’m trying to get the image url and not add Érik
– Victor Delicoli
background-image
wouldn’t be the element’s css, within the style attribute? Orbackground-image
is a custom attribute name?– Thomas
Thomas, background-image is inside the style attribute
– Victor Delicoli