Software Archive
Read-only legacy content
17060 Discussions

Change image source of a graphic button on click

Andre_R_
Beginner
198 Views

Hello,

this is my first attempt with Intel XDK and I hope anyone can help me!

I have placed a graphic_button and by clicking on, I want to change the "img src" of the button.

Here is my code:

<a class="uib-graphic-button default-graphic-sizing default-image-sizing hover-graphic-button active-graphic-button default-graphic-button default-graphic-text widget uib_w_11 d-margins media-button-text-bottom" data-uib="media/graphic_button" data-ver="0"

                                id="test">
                                    <img src="images/Arrow.png">
                                    <span class="uib-caption">Button</span>
                                </a><span class="uib_shim"></span>

The trigger of this graphic button has an action with the following custom script:

     /* graphic button  #test */

    $(document).on("click", "#test", function(evt)
    {
        /* your code goes here */ 
        document.getElementById(test).src="../images/X.png";
    });
    
    }

But this code has no effect! Can anyone help me, please.

Thanks in advance!

Regards

Andre

0 Kudos
1 Solution
Elroy_A_Intel
Employee
198 Views

I recommend doing the following:

 $(document).on("click", "#test", function()
    {
        $("#test img").attr("src","../images/X.png");

    });
    
    }

 

View solution in original post

0 Kudos
1 Reply
Elroy_A_Intel
Employee
199 Views

I recommend doing the following:

 $(document).on("click", "#test", function()
    {
        $("#test img").attr("src","../images/X.png");

    });
    
    }

 

0 Kudos
Reply