Creating a canvas element and setting its width and height attributes using jQuery

后端 未结 6 1748
天涯浪人
天涯浪人 2020-12-16 09:55

I was just trying to do the following in jQuery:

var newCanvas = $(\'\',{\'width\':100,\'height\':200,\'class\':\'radHuh\'});
$(body).append(n         


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-16 10:17

    Edit: This is slower, see comments below.

    This will likely be faster than any workaround posted here:

    var attributes = {width: 100, height: 100, class: "whatever"};
    $('').appendTo(document.body);
    

    Slightly less fancier, but it's esentially the same with less function calls.

提交回复
热议问题