Jquery append method issue on the IE browser

var nestedtablesettings = {
    "iDisplayLength": 20,
    "bLengthChange": false,
    "bFilter": true,
    "bSort": true,
    "bInfo": false,
    "drawCallback" : function() {
        var appendDownloadLink = $("table table td .dataTables_filter");
        appendDownloadLink.each(function(i, e) {
            var label = $('label', e);
            $(e).html('<a class="export-circuits" href >Export circuits</a>').append(label);

            $(".export-circuits").on("click", function(e){
                circuit = $(this).closest('tr').prev('tr').children('td').eq(1).text();
                hpath = "exportCircuits?organisationID="+getbusinessID+"&interfaceName="+circuit;
                $(this).attr("href", hpath);
            });
        });
    }
};

Open in new window


I am trying to add an export link on the nested datatable.  When I try to see my result on Chrome and Firefox, it is working perfectly.

The result on chrome and Firefox
<div id="nested-datatable-covertab_0_row_0_tab_0_row_0_tab_0_filter" class="dataTables_filter"><a class="export-circuits" href="">Export circuits</a><label>Search:<input type="search" class="" placeholder="" aria-controls="nested-datatable-covertab_0_row_0_tab_0_row_0_tab_0"></label></div>

Open in new window


On the IE, it removed the data from label elements.
<div id="nested-datatable-covertab_0_row_0_tab_0_row_0_tab_0_filter" class="dataTables_filter"><a class="export-circuits" href="">Export circuits</a>
<label></label>
</div>

Open in new window


From my research, IE has got some issue with jquery append method.

Any helps would be highly appreciated.
Yakup KAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971MultitechnicianCommented:
replace :
var label = $('label', e);

Open in new window

by :
var label = $('label', e);
alert(label);

Open in new window


if you see the data replace :
            var label = $('label', e);
            $(e).html('<a class="export-circuits" href >Export circuits</a>').append(label);

Open in new window

by :
            var label = "<label>" + $('label', e).html() + "</label>";
alert(label);
            $(e).html('<a class="export-circuits" href >Export circuits</a>').append(label);

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Yakup KAuthor Commented:
Thanks a lot Leakim. Excellent!.
Yakup KAuthor Commented:
Hi LeaKim,

That show the search box on the IE, but it removes the functionality of the search.  
With this implementation search does not work on any browsers now.

Do you have any ideas ?
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

leakim971MultitechnicianCommented:
what about :
var nestedtablesettings = {
    "iDisplayLength": 20,
    "bLengthChange": false,
    "bFilter": true,
    "bSort": true,
    "bInfo": false,
    "drawCallback" : function() {
        $("table table td .dataTables_filter").prepend('<a class="export-circuits" href >Export circuits</a>');
        $(".export-circuits").on("click", function(e){
            circuit = $(this).closest('tr').prev('tr').children('td').eq(1).text();
            hpath = "exportCircuits?organisationID="+getbusinessID+"&interfaceName="+circuit;
            $(this).attr("href", hpath);
        });
    }
};

Open in new window

Yakup KAuthor Commented:
Thanks for your help again. This solution is creating my previous issue again. When you append element like this, if you you click any links on the last level table, it duplicated the links because of datatable plugins.

<div id="nested-datatable-covertab_0_row_0_tab_0_row_0_tab_0_filter" class="dataTables_filter"><a class="export-circuits" href="">Export circuits</a><a class="export-circuits" href="">Export circuits</a><a class="export-circuits" href="">Export circuits</a><a class="export-circuits" href="">Export circuits</a><label>Search:<input type="search" class="" placeholder="" aria-controls="nested-datatable-covertab_0_row_0_tab_0_row_0_tab_0"></label></div>

Open in new window


That's why we tried like the following;

var label = $('label', e);
$(e).html('<a class="export-circuits" href >Export circuits</a>').append(label);

Open in new window


But, this solution removes the search box from the label.
leakim971MultitechnicianCommented:
it duplicated the links because of datatable plugins.

do you have a link or can reproduce that on jsfiddle ? I do'nt get it
Yakup KAuthor Commented:
jsfiddle

Thanks a lot for your help.

Please see the link on the jsfiddle. When you click on the inner table header, it duplicates the links.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Chrome

From novice to tech pro — start learning today.