Search code examples
dotless

how to change value dynamically variable


how to use dynamically dotless variables. I mean how to assign value dynamically in dotless file. Is there any way?

style.less file contain

@url_image: 

#head{ background: url(@url_image) no-repeat left top white;}

How can I assign a value at runtime?


Solution

  • When you say change dynamically in .less file, I am not sure why you wanna just change it in less file. If you just change it in .less file, you'll have to compile the file in order to navigative the change to style.min.css and style.css files, which you can't do programmatically.

    This is what you can do:

     $('#head').css('background-image', "url("new-source");
    

    So jquery/javascript is your best bet