<select>
<option value="America">America</option>
<option value="North America">North America</option>
</select>
We have an issue where in WP Forms we have a list of countries or regions, and we want to be able to disable any given one as a Parent, such as disabling "America" in the form above. IE. Europe, Great Britain, Spain. We’d like to disable Europe form being selected.
<script type="text/javascript">
(function( $ ) {
'use strict';
$(document).ready( function(){
var $option = $('option:contains("America")');
$option.attr('disabled',true);
});
})(jQuery)
</script>
I tried this, as I found it online, but the issue is that for North America, this tool will be disabled as the option "contains" America.
Is there a different "contains" term to use, that means this "specifically and only" in the field….?
2
Answers
You can try attribute Attribute selector.
Demo:
For your particular code:
But to disable several items I would use
jQuery::filter()
: