jQuery create element with attribute differences

后端 未结 2 1564
不知归路
不知归路 2021-01-02 02:49

Discovered something and am looking into a bit of incite as to why one way works and the other doesn\'t. Looks to be only an IE7 thing but as IE7, sigh, still needs some su

2条回答
  •  我在风中等你
    2021-01-02 03:10

    according to jQuery:

    Note: Internet Explorer will not allow you to create an input or button element and change its type; you must specify the type

    this doesn't work:

    $('', {
        type: 'text',
        name: 'test'
    }).appendTo("body");
    

    but this does:

    $('').attr({
        name: 'test'
    }).appendTo("body");
    

提交回复
热议问题