There are a couple of things I noticed in your code.
First you should not have the id
of an element, that's very bad practice.
Secondly, it's always a good idea to use a class
on an element
which you want to change or manipulate via jquery or javascript. It's much easier. As I noticed you didn't put on any of the parents wrapping your h5
tag
Anyways, here's one solution
Use a css class for your borders
.border-country{border:solid red 1px;}
AND Modify your jquery code
var lastElem=null;
$('#state').on('change',function(event){
var state= $(this).val();
// remove already existing borders on any country lists
$(lastElem).parent().parent().removeClass('border-country');
// add your own class
$(state).parent().parent().addClass('border-country');
// save current element in your lastElem variable and you can remove border when firing the second or so on events
lastElem=$(state);
});
I'm using the parent() function because of the second point I mentioned in my observations, you could avoid that by putting a mock class on your parent element wrapping the h5 tag.
If you had used a class we could have simply used
$('yourclass').removeClass('.border-country');
$('yourclass').addClass('.border-country');
Hope this helps and this should work!
Thx