I have a basic Generator for border radius, where the user types in the number of their choice and it inserts the number into the preview code. However I want to have a preview box that changes according to the number they have inserted. I am half way there but can’t seem to figure out the last bit.
HTML:
<label>Border Radius:</label>
<input name="border-radius" id="jj_input" class="jj_input" type="text" size="2" value='' onkeyup='changeRadius()' />
<span>px</span>
<div class="yourcode">
<p>border-radius: <span id="radius"></span>px; </p>
<p>webkit-border-radius: <span id="radius2"></span>px; </p>
</div>
<div id="preview">
<span class="preview_text">Preview Text</span>
</div>
Javascript:
function changeRadius(){
var jj_input = document.getElementById('jj_input').value;
document.getElementById('radius').innerHTML = jj_input;
document.getElementById('radius2').innerHTML = jj_input;
document.getElementById('preview').style.borderRadius = 'WHAT_GOES_HERE?' ;
}
Where is says “WHAT_GOES_HERE?”, I want this value to be the same as jj_input.
Any ideas?
We’re simply assigning the value of
element.style.borderRadiusto that ofjj_inputand concatenating inpx.