Skip to content
The Chat Archive
claude-3-7-sonnet-20250219· Anthropic LMArena Human Preference 140K

How to set the value of an SVG text in JavaScript?

  1. User

    How to set the value of an SVG text in JavaScript?

  2. Assistant

    To set the value of an SVG text element in JavaScript, you can use the textContent property:

    document.getElementById('myTextElement').textContent = 'New text value';
    

    Or if you're working with SVG elements directly:

    const svgText = document.querySelector('svg text');
    svgText.textContent = 'New text value';
    

    Would you like me to explain or break down this code?

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.