how to append option value in a specific index in jquery -


i tried append option value in particular position/index using jquery.

this code :

 function refreshdropdown(target,option){ var arrdatabases = getdatabases();   var numofdatabases = arrdatabases.length; var haspe= jquery.inarray("pe",arrdatabases) >=0 ; var onlype= (jquery.inarray("pe",arrdatabases) >=0 && numofdatabases == 1);          if( !haspe && !onlype && numofdatabases !=0){             jquery(".lookforselector             option[value='publishers']").remove();  **jquery(target).append(jquery('<option>     </option>').val('publishers').html('publisher'));**  } } 

in above code want append value "publishers" caption "publisher" @ 19th position. getting appended in last index. value variable target ".lookforselector".

appreciate timely help.

if know target you're appending to:

$(target + ' :nth-child(19)').after("<option value='publishers'>publishers</option>"); 

here's fiddle appending middle of select: http://jsfiddle.net/e3wpg/


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -