How to overwrite inline style for <section> element tag?

25 views
Skip to first unread message

Ben Stover

unread,
Sep 19, 2015, 8:16:08 AM9/19/15
to Greasemonkey Users
Assume I have a webpage with the following HTML code:

<section itemscope="itemscope".... style="margin-top: 20px;">
....
</section>


How can I overwrite the "margin-top" inline style value by e.g. 10 ?

Aftwerwards the following statement should become effective:

<section itemscope="itemscope".... style="margin-top: 10px;">

If necessary jQuery can be used.

Thank you
Ben


Message has been deleted

Tithen Firion

unread,
Sep 20, 2015, 4:27:53 PM9/20/15
to greasemonkey-users
To edit this value just use
element.style.marginTop = "10px";

If you have only one section element with itemscope attribute set to itemscope, you can find it using this code:
document.querySelector("section[itemscope=itemscope]");

So your one-liner would be:
document.querySelector("section[itemscope=itemscope]").style.marginTop = "10px";
Reply all
Reply to author
Forward
0 new messages