Код: Выделить всё
Uncaught TypeError: prev.setAttribute is not a functionvar svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
const control_W = 550; //width of slider
const control_H = 300; //Height of slider
const arrowHeight = 10;
svg.setAttribute("id", "sliderControl");
svg.setAttribute("overflow", "visible");
svg.setAttribute("viewBox", "0 0 " + control_W + " " + control_H);
svg.setAttribute("width", control_W);
svg.setAttribute("height", control_H);
var svgNS = svg.namespaceURI;
//---------DEFS----------v
//create an add a section to svg
var defs = document.createElementNS(svgNS, 'defs');
svg.appendChild(defs);
//create and add a prototype svg 'prev' & 'next' arrow to the section
var prev = document.createAttributeNS(svgNS, 'path');
prev.setAttribute("d", "M 0,0 v -5 l -8,5 l 8,5 Z");
prev.setAttribute("fill", "#333333");
prev.setAttribute("stroke", "none");
prev.setAttribute("id", "prev");
defs.appendChild(prev);
//snipped the next arrow prototype
//---------DEFS----------^
//snipped
// create and set up the svg section
const y_prev = document.createElementNS(svgNS, "use");
y_prev.setAttribute("x", "100");
y_prev.setAttribute("y", "100");
y_prev.setAttribute("id", "y_prev");
y_prev.setAttribute("fill", "silver");
y_prev.setAttribute("xlink:href", "#prev");
datePickerTitle.appendChild(y_prev);
//snipped next arrow clause[/code]
Подробнее здесь: https://stackoverflow.com/questions/796 ... erated-svg
Мобильная версия