Skip to content

Instantly share code, notes, and snippets.

@JARVIS-AI
Forked from tzi/important.css
Created March 15, 2021 09:48
Show Gist options
  • Select an option

  • Save JARVIS-AI/b04bd7da23fe0ec1f0f69520d3e682c3 to your computer and use it in GitHub Desktop.

Select an option

Save JARVIS-AI/b04bd7da23fe0ec1f0f69520d3e682c3 to your computer and use it in GitHub Desktop.
How to set an !important css property in javascript
(function()
var target = createElement( '<a class="target" href="javascript:;" title="Share this at Diaspora*">Diaspora Share Button</a>' );;
if (noDataURI == 1) {
target.setAttribute( 'background-image', 'url( ' + imagesPath + 'diaspora-share-button.png ) !important' );
}
<!DOCTYPE html>
<html>
<head>
<title>Test navigator</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script type="text/javascript" src="bg-image.js"></script>
<body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment