Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is possible change css from a xpath node?

For example in javascript using getelementbyid:

document.getElementById("theID").style.width="100%";

can i change the css from the node retrieved by xpath like with getelementbyid?

like image 543
fpilee Avatar asked May 06 '26 15:05

fpilee


1 Answers

Yes, i did it like this:

var xpath = 'your xpath';

var matchingElement = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

matchingElement.style.color = "blue";
like image 188
Aleksander Maj Avatar answered May 08 '26 06:05

Aleksander Maj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!