Issue #3626💬 AnsweredOpened July 16, 2021by san-1230 reactions

How to set src of video tag at dynamic?

Quick answerby stf1981

I think I have something like that made with a custom component. Maybe it helps

Read full answer below ↓

Question

Hi @artf , Hi I have drag and drop video tag and button from blockmanager, On Clicking the button , I need to change the url to src. But not working, Please guide me. editor.BlockManager.add("html/video", { label: <div> <img src="../../../Images/SiteBuilder/video.svg"/> <div class="my-label-block">Video</div> </div>, category: 'UI Controls', tab: 'UI Controls', id: 'UI Controls', content: <video id="video1" src="../../../Images/Jotun/Media21-1.m4v"id="TestVideo" controls type="video/mp4">, }); Button Event: va url = "../../test.mp4"; $("#video1").attr('src', url); Its not applied, Let me know...

Answers (4)

stf1981July 22, 2021

I think I have something like that made with a custom component. Maybe it helps

artfJuly 29, 2021

If you need to update only the block content (eg. the change will be applied on new dragged blocks) you can change it in this way: if you need to change Components in the canvas, I'd recommend reading more in detail Components

san-123July 30, 2021

,Thanks @artf and stf1981 for your response, Actually I drag and drop multiple videos with generated Random number to Id attribute. In this case How to update src specific selected video?

I gets failed to update src.

GJSBlockMay 17, 2026

Thanks for reporting this, @san-123. Great question about How to set src of video tag at dynamic?. The recommended approach with GrapesJS is to use the event-driven API. Start here: Check the GrapesJS documentation for your specific module Look for the on() event listener method Most operations can...

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.