Estaba tratando de determinar el tamaño de este rectángulo por parte del usuario:
<svg width=parseFloat(Rectangle1.width) height=parseFloat(Rectangle1.height)> <rect width=parseInt(input1int) height=parseInt(input2int) style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" /> </svg>con este código:
class Rectangle{ constructor(height, width){ this.height = height; this.width = width; }; function createRectangle(this.height,this.width){ var input1 = document.getElementbyId("1stinput").value; var input2 = document.getElementbyId("#2ndinput").value; var input1int = parseFloat(input1); var input2int = parseFloat(input2); var Rectangle1 = new Rectangle(this.height=input1int, this.width=input2int);}; };pero tengo un total de cinco errores para mí:
Uncaught SyntaxError: Unexpected identifier index.html:25 Error: <svg> attribute width: Expected length, "parseFloat(Recta…". index.html:25 Error: <svg> attribute height: Expected length, "parseFloat(Recta…". index.html:26 Error: <rect> attribute width: Expected length, "parseInt(input1i…". index.html:26 Error: <rect> attribute height: Expected length, "parseInt(input2i…". No sé lo que significan, así que una vez más solicito su apoyo de codificación financiera .
Eso no es html válido. Si desea establecer el width de un elemento dinámicamente. Debe configurarlo en JavaScript. Me gusta
document.querySelector("svg").setAttribute('width', parseFloat(Rectangle1.width))