How can I add Alt Text to an image?

Hi @sweetdavida, welcome to the forum!

I can think of a jQuery solution… how comfortable are you with that?

Maybe someone else has a more Anvil based approach… but I couldn’t come up with one…

This should work… in your form code:

js.call_js("add_alt_text", "Bad", self.image_1)

then in your native libraries

<script>
  function add_alt_text(alt_text, component){
    component = component.v._anvil.element;
    component.attr("alt", alt_text);
  };
</script>
3 Likes