jQuery create element with attribute differences

后端 未结 2 1547
不知归路
不知归路 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:29

    The answer can be found in the API for the jQuery() function itself.

    Note: Internet Explorer will not allow you to create an input or button element and change its type; you must specify the type using for example. A demonstration of this can be seen below:

    Unsupported in IE:

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

    Supported workaround:

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

提交回复
热议问题