Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prepend/append works in Chrome and Firefox but not IE11 and Edge

Trying to prepend data inside a text box in Chrome and Firefox works. Get error: SCRIPT438: Object doesn't support property or method 'prepend' in IE11 and Edge. Thx

    function init_TGs(){
        if (confirm("Initialize TinyG's?")){
            $.ajax({
                type: 'POST',
                url: "init_TGs", 
                data: 'None',
                success: function(result){
                    if (result != ''){
                        var rslt= result;
                        var item = document.getElementById('TextArea1');
                        item.prepend(rslt);
                    }}
                });
            }};
like image 888
creeser Avatar asked Feb 23 '18 01:02

creeser


1 Answers

Or, instead of adding a new polyfill you can use insertBefore function which is supported by all browsers:

var rslt= result;
var item = document.getElementById('TextArea1');
item.insertBefore(rslt, item.childNodes[0]);
like image 195
Sergiu Avatar answered Oct 16 '22 11:10

Sergiu