javascript - custom font selector only changes font once -
i'm @ loss, i'm trying allow users select font-family of text output. code boils down this:
<div id='output'> quick brown fox jumps on lazy dog </div> <select id='font-select'> <option value='lucida console'>lucida console</option> <option value='courier new'>courier new</option> <option value='consolas'>consolas</option> </select>
with jquery follows:
$(document).ready( function() { $('font-select').on( 'change', function() { $('output').css( 'font-family', $('#font-select').val() ); console.log( 'font changed' ); }); });
i know on-change event fires every time select different font, font in div changes first time choose one. after still 'font changed' notice in console, no actual change in #output div.
i've tried changing to
$(document).on( 'change', '#font-select', ....
i've tried changing id's classes , selecting via class
$('.font-select').change( ....
with same results. have advice?
the issue selectors used. when trying access element through id suppose add # in front.
here [fiddler][1] works fine , solve issue
hope helps.
[1]: https://jsfiddle.net/rajsnd08/nfh5craz/
Comments
Post a Comment