on issue you have is in one place you seem to have a variable names fresizeSizeNOPX
then later on you have $("#px").val("fresizeSizeNOPX"); which is a string value, not the value of the variable you used earler second issue, or confusion, what do you think or want "this" to be in the selector: $(this).bind('click', function(event, ui) { On Jan 26, 6:10 am, Mircea <i...@amsterdamsat.com> wrote: > I have the following function that should append or prepend a dynamic > value to a select with id #px. The dynamic value is not in the select > DOM from the start so I have to append it to make it work. > > The problem is that the new created value is not shown until I click > on the select dropdown, the DOM does not generate that value until I > click and drop down the list. What should I do? > > This is my code: > > $(document).ready(function() { > $(this).bind('click', function(event, ui) { > > var fresizeSize = $('.cica').css("font-size"); > var fresizeSizeNOPX = > $('.cica').css("font-size").replace(/[^0-9]+/ > g,''); > > var newTr = '<option class="option" value="' + fresizeSize + '" > label=' + fresizeSizeNOPX +'>' + fresizeSizeNOPX +'</option>'; > > $('#px').prepend(newTr); > $("#px").val("fresizeSizeNOPX"); > > }); > }); > > Thank you.