How can I change css stylesheet with dart?

Tags: html,css,dart,dart-polymer

Problem :

I'm working on a project for an exam and I need to change the stylesheet's name in the page. How can I do this with Dart? I've seen that I can edit every attribute of my css from Dart but I've already made others css that I would like to use in my page. For example, I have this in my html page:

<link href="stile.css" rel="stylesheet" type="text/css">

I need to edit the page to make this

<link href="stile-blu.css" rel="stylesheet" type="text/css">

How can I do this?

Solution :

Assuming your <link ...> element is in the <head> element

document.querySelector('#button').onClick.listen((_) {
  var stile = document.head.querySelector('link[href="stile.css"]');
  stile.attributes['href'] = 'stile-blu.css';

If you add an id attribute to your link element the selector can be simplified

<link id="mystyle" href="stile.css" rel="stylesheet" type="text/css"> 
document.querySelector('#button').onClick.listen((_) {
  var stile = document.head.querySelector('#mystyle');
  stile.attributes['href'] = 'stile-blu.css';

    CSS Howto..

    How to create new top headers for weebly

    How do I get IE to display CSS DIV tables properly?

    How to modify the link text(html link) properties using css

    how to solve css check box checking issue

    How to add a border-bottom similar to Yahoo! when you scroll the page?

    Prestashop - How to edit views [closed]

    How to scroll the fixed content in CSS and HTML

    How to vertically and horizontally centre text with a variating font size in CSS

    how to create horizontal drop-down menu with javascript for website?

    How to route requests in codeigniter so we can serve static css, js and img files?

    How do I add a custom font to the part of ConvertTo-HTML?

    how to write a css that only can be visible on desktop in bootstrap

    How do I know which CSS is overriding my background image?

    How to reset inline css applied by jquery?

    CSS - How to Style a Selected Radio Buttons Label?

    CSS: How to get a positioned div to resize horizontally with window instead of getting scrollbars

    How to center text in the middle of the responsive circle, (text is responsive too)?[css/html only]

    How add symbol in CSS for element?

    Disable the centring image function in a slideshow plugin?

    How to do like this list using
  • and CSS?
  • How to create a modal popup using javascript and CSS

    How to link to an image from a CSS file when using the resource plugin 1.2.14

    How to animate a ball travelling pre-defined paths in HTML5, Javascript and CSS?

    What is .htc file ?How it works in Internet explorer

    How do I draw a Diagonal div?

    how to place the images exactly in menu position

    How to load an onScroll background image before user scrolls to them?

    How to hide and show a separate div with CSS

    How to change accordion css to plain white?

    How to set gulp autoprefixer that it will be prefix css when I save my project