How to change selected item's text in a select list with jQuery -
in script below, "my_theme" element select list of directory listing.
when "change" event fired, jquery called , triggers "get" find out if selected folder has style.css file. returns true/false.
all works fine. i'm trying determine how decorate item in select list depending on outcome of get.
for example, if false, want make selected item's background gray , append text option name label.
so, if selected item in list "alpha", , $.get returns false, text should become "alpha (inactive)".
$('#my_theme').change ( function() { //check if folder has style.css file $.get('<?php echo get_bloginfo('template_directory') ?>/getstyle.php', {theme: myimage}, function(data){doactive(data);}); } ); function doactive(data){ if(active){ //if stylesheet missing, append label " (inactive)" $('#my_theme :selected').text() = $('#my_theme :selected').attr('value') + ' (inactive)'; }
the option's "value" attribute same label. }
function doactive(data){ if(active){ //if stylesheet missing, append label " (inactive)" $('#my_theme :selected').text($('#my_theme :selected').attr('value') + ' (inactive)'); }
Comments
Post a Comment