Skip to content

Instantly share code, notes, and snippets.

@drabbytux
Last active March 11, 2017 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drabbytux/6d1d2285fc03f4f77fbc020f2336bb34 to your computer and use it in GitHub Desktop.
Save drabbytux/6d1d2285fc03f4f77fbc020f2336bb34 to your computer and use it in GitHub Desktop.
Make 'Pick an option' the default choice Javascript for theme.js
$(document).ready(function() {
if( typeof(productOptions ) != "undefined" ){
for(i=0;i<productOptions.length;i++) {
if (['a', 'e', 'i', 'o', 'u'].indexOf(productOptions[i][i].substr(0, 1).toLowerCase()) !== -1 ) {
$('.single-option-selector:eq('+ i +')')
.filter(function() {
return $(this).find('option').length > 1
})
.prepend('<option value="">Pick an ' + productOptions[i][i] + '</option>')
.val('')
.trigger('change');
} else {
$('.single-option-selector:eq('+ i +')')
.filter(function() {
return $(this).find('option').length > 1
})
.prepend('<option value="">Pick a ' + productOptions[i][i] + '</option>')
.val('')
.trigger('change');
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment