简体   繁体   中英

JQuery - Has Internet Explorer problems with dynamic tables?

My script creates dynamic input fields inside a table. When I try to run a function after an action it doesn't work (In Internet Explorer, everywhere else it's working fine) I found out that everything works properly, when the input fields come from static HTML.

Do you know something if IE has some problems with dynamically inserted input fields?

The code is simple and works everywhere else:

   .append($('<input>')
            .attr('type', 'text')
            .attr("name","avz_anzahl["+avz_array+"][]")
            .attr("size","3")
            .attr("bez","avz_anzahl")
            .attr("nr","")
            .attr("onblur","test();")
            .attr("value", "")

Somehow the follwing function doesn't get executed in Internet Explorer:

 function test() 
  { alert("ok"); }

Do you know why?

In order to make sure jQuery events are working, use proper jQuery events , like bind or blur .

Also jQuery have more elegant way to create html element:

$("input", {
    type: "text",
    name: "avz_anzahl["+avz_array+"][]"
    size: 3,
    bez: "avz_anzahl",
    nr: "",
    blur: test,//make sure there is no (),
    click: function(){
    },
    value: ""
}).appendTo(SomeElement);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM