JavaScript Find <style> tag by id or attribute find style attribute using jquery,jquery find style attribute,jquery

I would like to dynamically remove or disable a <style> tag

that looks like this

<style type="text/css" id="cssx/portal/simple-sidebar.css" designtr="cssx/portal/simple-sidebar.css">


#wrapper {
    padding-left: 0;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
}

#wrapper.toggled {
    padding-left: 250px;
}

#sidebar-wrapper {
    z-index: 1000;
    position: fixed;
    left: 250px;
    width: 0;
    height: 100%;
    margin-left: -250px;
    overflow-y: auto;
    background: #000;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
}

</style>

if I have the id or my own defined designtr property, I can't seem to disable or remove it like so:

        var id = 'x';
        var designtr = 'x';

        document.getElementById(id).disabled = true;  //doesn't work, throws an error saying element is null
        $('style[designtr="' + designtr + '"]').remove();   //doesn't work, although strangely no error thrown

I read somewhere that even with HTML5 style tags can't have a valid id attribute.

All I want to do is either remove or disable a style tag, given some unique id that I have in hand.

Answer:1

Works like a charm:

document.getElementById('remove').onclick = function () {
  document.getElementById('styl').remove();
};
<div>Some Div Content</div>
<button id="remove">remove</button>
<style id="styl">div{background-color: red}</style>
Answer:2

I really need help. I am a newbie programmer and really not sure how can i do this in joomla. I need to create a pop up or iframe that pass variable from the parent page. Basically what is to happen ...

I really need help. I am a newbie programmer and really not sure how can i do this in joomla. I need to create a pop up or iframe that pass variable from the parent page. Basically what is to happen ...

  1. create popup iframe javascript
  2. create iframe popup
  3. how to create iframe popup window
  4. how to create iframe popup window in asp.net

I'm trying to create a client-side only application using Firebase as a database service and I'm experiencing some difficulties defining a security rules that will allow multiple 'admin' users access ...

I'm trying to create a client-side only application using Firebase as a database service and I'm experiencing some difficulties defining a security rules that will allow multiple 'admin' users access ...

While using Bootstrap 2.3, Bootbox and viewing the result in Google Chrome on Ubuntu you get a less than appealing border around the button because it is auto-focused. I havent found any api hooks to ...

While using Bootstrap 2.3, Bootbox and viewing the result in Google Chrome on Ubuntu you get a less than appealing border around the button because it is auto-focused. I havent found any api hooks to ...

  1. bootbox remove autofocus

I have about 30-40 images that I'm currently attempting to reload. However, I still get this "flicker" when I hover over a image. The images disappear for a couple of milliseconds and then comes back. ...

I have about 30-40 images that I'm currently attempting to reload. However, I still get this "flicker" when I hover over a image. The images disappear for a couple of milliseconds and then comes back. ...