Skip to content

Instantly share code, notes, and snippets.

@wmh
Last active September 11, 2017 03:19
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 wmh/62abc0abe89ee2650c16 to your computer and use it in GitHub Desktop.
Save wmh/62abc0abe89ee2650c16 to your computer and use it in GitHub Desktop.
Select My Country
// https://kktix.com/users/edit
$('#user_place_id').val($('#user_place_id option:contains(臺灣)').attr('value'));
// https://www.paypal.com/signup/account
['Taiwan','台灣','臺灣','台湾','Taïwan'].forEach(function (cn) {
$('select option:contains('+ cn +')').each(function () {
var $this = $(this);
$this.click();
$this.closest('select').val($this.val());
});
});
// https://www.paypal.com/signup/account
document.querySelectorAll('select option').forEach(function (ele) {
if (ele.innerText.indexOf('台湾') != -1) {
var val = ele.value;
while (true) {
ele = ele.parentNode;
if (ele == null || ele.tagName.toLowerCase() == 'body') {
break;
}
if (ele.tagName.toLowerCase() == 'select') {
ele.value = val;
}
}
}
});
// jQuery
$('#country_id').val($('#country_id option:contains(Taiwan)').attr('value'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment