Answer the question
In order to leave comments, you need to log in
How to add page title to alt?
There is a site where the user adds text with pictures to the articles site on modx evo, but this does not change the essence, you need to take the title of the h1 page and transfer its content to all the pictures that are on the page inside the [*content*] tag.
I tried something like this but it doesn't work. I am new to js and jq.
<header><h1 id="in">[*pagetitle*]</h1></header>
<script>
$( "img" ).each(function( ) {
var clo = $(this).siblings('h1').text();
$(this).attr('alt', clo);
});
</script>
<div class="content">
[*content*]
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question