I'm looking for the correct JavaScript code (not JQuery) which will convert a div width from 100% to 1000px Browser width & lt; 1000 pixels Browser size & gt; 1000px if code will change to 100% Before learning jQuery I want to learn Javascript! I can get load of JQuery solution but I want to learn JS! In Bela I want to change the div element named "red". The reason for this is that the minimum width: 1000px; That is why it is not supported and therefore I want a work solution. Thank you very much for any help. Bela's link is here:
javascript:
window.onresize = function () {Var widthViewport = window.innerWidth || Document.body.clientWidth; Var el = document.getElementById ('red'); If (widthViewport & lt; 1000) {// adding a classname that specifies the fixed width el.className + = 'fixed_width'; } Else {// classname}, which fixes width at 1000px el.className = el.className.replace (/ (* b * s * fixed_width \ b) + /, ''); }}; CSS: .fixed_width {width: 1000px; }
No comments:
Post a Comment