function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Narender KumarNarender Kumar 

Trouble in replace image src

Hello Everyone,

I want to change image src in lightning component from lightning controller.
<aura:component >
    <img aura:id="imgid" src="/files/image_name.jpg" ></img>
    <ui:inputCheckbox aura:id="checkbox" label="Select?" change="{!c.onCheck}"/>
        onCheck: function (cmp, event, helper) {
            var checkCmp = cmp.find("imgid");
            checkCmp.set("v.value", "/files/new_image_name.jpg");

But with cmp.find("imgid") not able to change the src of image. Any one have a syntax example that they know works.
Ricardo Coutinho 7Ricardo Coutinho 7

The cmp.find only finds the component, then you need to get the value.
var checkCmp = cmp.find("imgid").get("v.value");

Narender KumarNarender Kumar
Thanks! Yes i understand that but i need to get src value from simple HTML img tag and replace it. Did you know how to do that ?
Ricardo Coutinho 7Ricardo Coutinho 7
After you add the get("v.value");

It should work, because i think what's wrong with your code it's that you're trying to change something that you didn't find yet.
Narender KumarNarender Kumar
Thanks for the answer. 

Yes i am fail to find how to get src value in lightning. If you have any solution please help us.
Hamza AlviHamza Alvi
Need help on this exact issue as well.