A relatively simple solution, using a select element to handle the language-choice:
$('#language').change(function(){
// storing the language chosen in the select element
var v = this.value;
/* iterates over all li elements, and hides them,
then filters the matched elements to see which elements
contain the relevant language in the 'language' attribute: */
$('ul li').hide().filter(function(i){
return this.getAttribute('language').indexOf(v) !== -1;
// shows the elements that contain the relevant language:
}).show();
});
JS Fiddle demo.
Or a slightly different approach:
$('#language').change(function () {
var v = this.value;
$('ul li').each(function(){
var l = this.getAttribute('language');
return $(this).toggle(l.indexOf(v) !== -1);
});
});
JS Fiddle demo.
Both the above work with the following HTML:
<label for="language">Show:</label>
<select name="language" id="language">
<option>English</option>
<option>French</option>
<option>German</option>
</select>
<ul>
<li language="English">Australia</li>
<li language="English">America</li>
<li language="French">France</li>
<li language="English French">Canada</li>
<li language="German">Germany</li>
</ul>
Incidentally please note the corrected spelling of 'language' in the final li element.
Further, it'd be better to correct your HTML to use a valid (under HTML5) data-* attribute, such as data-language (to use the obvious):
<ul>
<li data-language="English">Australia</li>
<li data-language="English">America</li>
<li data-language="French">France</li>
<li data-language="English French">Canada</li>
<li data-language="German">Germany</li>
</ul>
And the above code amended, to use that modified HTML:
$('#language').change(function(){
// storing the language chosen in the select element
var v = this.value;
/* iterates over all li elements, and hides them,
then filters the matched elements to see which elements
contain the relevant language in the 'language' attribute: */
$('ul li').hide().filter(function(i){
return $(this).data('language').indexOf(v) !== -1;
// shows the elements that contain the relevant language:
}).show();
});
JS Fiddle demo.
$('#language').change(function () {
var v = this.value;
$('ul li').each(function(){
var self = $(this),
l = self.data('language');
return self.toggle(l.indexOf(v) !== -1);
});
});
JS Fiddle demo.
References:
language="English"elements, or show them? If you want to show Canada as well, then add all the relevant attributes/attribute-values, and explain which should be shown and which hidden.