点击使SVG可resize

如何通过jQuery UI“点击”设置SVG可resize?

jsfiddle例子

HTML

    

jQuery的

  $('#svg1').click(function () { $("#svg1").resizable(); }); 

来自Alvin.K的解决方案

基于上面评论中的示例 ,您可以尝试此调整,不会更改SVG,只会更改DIV大小。

  $('body').append('
'); var svg = document.createElementNS('http://www.w3.org/2000/svg', "svg"); svg.setAttributeNS(null, "viewBox", "0 0 200 200"); $('div').append(svg); var square = document.createElementNS('http://www.w3.org/2000/svg', "rect"); square.setAttributeNS(null, "width", "200"); square.setAttributeNS(null, "height", "200"); square.setAttributeNS(null, "x", "0"); square.setAttributeNS(null, "y", "0"); square.setAttributeNS(null, "style", "fill:#FF0000"); $('svg').append(square); $('div').draggable({ handle: 'rect' }).resizable({ aspectRatio: 1.0 });