I'm utilizing a plugin to produce a real clever jquery choose (dropdown) menu.

The html necessitates the following format:

<select>
<option value="0" selected="selected" data-skip="1">Choose an Artist</option>
<option value="1">Title</option>
<option value="2">Title</option>
<option value="3">Title</option>
<option value="4">Title</option>
</select>

I wish to use wordpress to show certain pages inside a choose menu:

<?php wp_dropdown_pages('child_of=96'); ?>

Wordpress effectively returns a choose menu of all the correct pages. I want a jquery means to fix place this prior to the first choose element: <option value="0" selected="selected" data-skip="1">Choose an Artist</option> i need jquery to assign a choice value to another choose item (see markup above). So essentially, I want a jquery means to fix append that line prior to the first choose item as well as assign a consecutive option value (i++) to another choose item.

Thanks ahead of time, and Hopefully is sensible.

As lengthy as possible distinctively identify your choose area (e.g. id or class title) something similar to this will do what you would like:

var select = $('select'); // Or according selector
select.prepend('<option value="0" selected="selected" data-skip="1">Choose an Artist</option>');
$('option', select).each(function(index) {
    $(this).attr('value', index);
});

Essentially the final loop sets the need for each use of the choose area to it's index.

You have to prepend your brand-new list choice to your select after which loop within the options and place value attribute having a number that increases every time the function loops.

    $("select").prepend("<option selected='selected' data-skip='1'>Choose an Artist</option>'");
       var i = 1;
    $("select option").each(function() {
       $(this).attr("value",i);
       i++;
     });

Fiddle: jsfiddle.net/67de7/1