The editors. In jQuery you can do this.
replist=[ ['button-fancy', 'btn btn-primary btn-sm' ], ['button-morefancy', 'btn btn-default btn-lg'] ]; $(document).ready(function(){ for(i=0; i<replist.length; i++){ elems=document.getElementsByClassName(replist[i][0]); for(j=0; j<elems.length; j++){ elems[i].style.className = " "+replist[1]; } } }
Since my original post was understated, I updated it with a bit of efficient code. Although it has two loops, the outer loops depend on how many classes you put, and the inner loop depends on the number of buttons. Say you added 5 classes and 20 buttons for each class. The style will be updated 100 times. This is true taxation, but the amount of tax is not very significant in terms of utility.
Secondly, you can add it to the top of the document or a completely different file to help with debugging, but yes, since it is separate from CSS, it will be a little difficult to debug.
Thirdly, this is the purpose of the prototype. In the final version, you can search and replace to replace the original buttons.
Fourth, the style of the entire .button-fancy class is .button-fancy . I replaced the .button-fancy class in which the DOM Tree will not find it. Since my goal is to reproduce the search and replace functionality. Validating an element (in firefox) will result in it not having any button class.
Finally, this is for PROTOTYPE PURPOSE. And it should be taken as such. It is not right. This is not a good practice. But this is a quick and dirty way to check. He is trying to imitate what SASS does, but also the client. This is not production ready. But it does not require recompilation with every CSS update. You can use SASS, but you can only update SASS CSS when you see fit.
Thanks.
source share