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.

Reply via email to