Reputation:
Please check this fiddle and see why it does not work in IE8.
http://jsfiddle.net/mostafatalebi/6WQ9x/
There are two list and one container.
List A is the list of all fields, and the second list is empty.
then there is a container which holds all the sub-branches of of all branches. then by clicking on a branch, the jquery code copies the set of matched elements from the container and clones them into the empty second . This works in FF but fails in IE. you can play with fiddle. Here is the jquery:
$(document).ready(function(){
$('#branches').children('option').on('click', function(){
var branch = $(this).val();
var subholder = $('#subbranch-holder');
$('#sub').empty();
$('#sub').html("<option value='false'>انتخاب زیر شاخه ها</option>");
// console.log(subholder.children('option').length);
subholder.children('option').each(function(){
if($(this).attr('id') == 'par'+branch)
{
$(this).clone().appendTo("#sub");
}
});
});
});
Upvotes: 1
Views: 84
Reputation: 4195
Use jQuery version 1.* instead version 2.*.
And change this line :
$('#branches').children('option').on('click', function(){
To this :
$('#branches').on('change', function(){
EDIT:
It will be better if you use valid html,so your code will work in other browsers .
See this one :
http://jsfiddle.net/6WQ9x/9/
Upvotes: 1