JSFiddle - React, Tailwind, and code Playground

by Osman Salihovic

HTML

<input type='text' id='txtField001' class='txtField150'>foo</input>  
<input type='text' id='txtField002' class='txtField10'>bar</input>  
<input type='text' id='txtField001' class='txtField75'>foo</input>  
<br />
<div id="test">Click here to test the code! </div>

CSS

.txtField1 ... .txtField50 {
    width: 50px;
}

.txtField50 ... .txtField100 {
    width: 80px;
}

.txtField100 ... .txtField150 {
    width: 120px;
}

JavaScript

$('#test').click(function(){    
    $("input").each(function() {
     var x = $(this).attr('class');
     x = $(this).attr('class').match(/\d+/);
     $(this).attr('style', 'width:' + x + 'px');  
    });
})