javascript - Repeating a character across the full width of an element -


i trying write function using javascript , jquery (since i'm using jquery site) detect width of view port , output character repeated across full width.

i trying make website looks unix terminal , table headers use equal sign repeat across width of screen (tables set width: 100%;). know make simple image of equal sign , set repeat-x using css on empty header row prefer text. have been playing around arrays , have far.

var windowwidth =$(window).width(); document.write( array( windowwidth ) ).join( '=' ) ); 

i know broken, left off because haven't been able figure out search terms should using find answer. if wouldn't mind either helping me write or point me in right direction appreciate it.

this can improved, by:

  • appending single character body, , width, remove it.
  • divide width of body width of character number of times repeat character.

example

var $char = $('<span>').css({ padding: 0, margin: 0 }).text('=').appendto('body'),     charwidth = $char.width(),     numberofchars = parseint(( $('body').width() / charwidth ).tofixed(), 10);  $char.remove(); document.write( array(numberofchars).join('=') ); 

here's fiddle


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -