Last active
March 11, 2017 12:40
-
-
Save drabbytux/6d1d2285fc03f4f77fbc020f2336bb34 to your computer and use it in GitHub Desktop.
Make 'Pick an option' the default choice Javascript for theme.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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