8 examples of 'remove inline css jquery' in JavaScript

Every line of 'remove inline css jquery' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
20function _cleanInlineCSS(inlineCSS, toRemove){
21 var inlineCSSArray = inlineCSS.split(';');
22 var toRemoveArray = toRemove.split(' ');
23
24 var cleaned = '';
25 var keep;
26
27 for (var i = 0, j = inlineCSSArray.length; i < j; i++) {
28 keep = true;
29 for (var a = 0, b = toRemoveArray.length; a < b; a++) {
30 if (inlineCSSArray[i] === '' || inlineCSSArray[i].indexOf(toRemoveArray[a]) !== -1) {
31 keep = false;
32 }
33 }
34 if(keep) {cleaned += inlineCSSArray[i] + '; ';}
35 }
36
37 return cleaned;
38}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

29function removeCss(document: Document, ref: number) {
30 if (injectedCache[ref] == null) {
31 return;
32 }
33 const head = getHead(document);
34 head.removeChild(injectedCache[ref]);
35 delete injectedCache[ref];
36}
20function removeSSRStyles(id) {
21 const jssStyles = document.getElementById(id)
22
23 if (jssStyles && jssStyles.parentNode) {
24 jssStyles.parentNode.removeChild(jssStyles)
25 }
26}
24export function removeJavascriptHrefs({rootElement}) {
25 const elements = Array.from(rootElement.querySelectorAll('*[href^="javascript:"]'))
26 elements.forEach(element => {
27 // We should keep some href value there to not change the link's appearance, but it should
28 // not be resolvable. So just keep the 'javascript:' there, for lack of better idea.
29 element.setAttribute('href', 'javascript:')
30 })
31}
24export function InjectCSS(css) {
25 var elem = document.createElement('style');
26 elem.setAttribute('type', 'text/css');
27 if (elem.styleSheet) {
28 elem.styleSheet.cssText = css;
29 } else {
30 elem.appendChild(document.createTextNode(css));
31 }
32 var head = document.head || document.getElementsByTagName('head')[0];
33 head.appendChild(elem);
34}
36function removeStyle(id) {
37 const element = document.getElementById(id)
38 if (element) {
39 element.remove()
40 }
41}
11function injectStyle(css) {
12
13 if (riot.render) return // skip injection on the server
14
15 if (!styleNode) {
16 styleNode = mkEl('style')
17 styleNode.setAttribute('type', 'text/css')
18 }
19
20 var head = document.head || document.getElementsByTagName('head')[0]
21
22 if (styleNode.styleSheet)
23 styleNode.styleSheet.cssText += css
24 else
25 styleNode.innerHTML += css
26
27 if (!styleNode._rendered)
28 if (styleNode.styleSheet) {
29 document.body.appendChild(styleNode)
30 } else {
31 var rs = $('style[type=riot]')
32 if (rs) {
33 rs.parentNode.insertBefore(styleNode, rs)
34 rs.parentNode.removeChild(rs)
35 } else head.appendChild(styleNode)
36
37 }
38
39 styleNode._rendered = true
40
41}
69export function insertCSS(css) {
70 var style = document.createElement("style")
71 style.textContent = css
72 document.head.insertBefore(style, document.head.firstChild)
73}

Related snippets