javascript - Add style to element from user input -


i have basic generator border radius, user types in number of choice , inserts number preview code. want have preview box changes according number have inserted. half way there can't seem figure out 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 says "what_goes_here?", want value same jj_input.

any ideas?

document.getelementbyid('preview').style.borderradius = jj_input + 'px'; 

we're assigning value of element.style.borderradius of jj_input , concatenating in px.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -