Mike Muller
Mike Muller

Reputation: 2297

Copying the contents of an H2 tag on a page to a series of spans inside a div

I have an H1 tag on a page with an ID of "Topic Name

<h1 id="topicName"><a href="/link here">News You Can Use</a></h1>

I need to copy the text inside the H1 and apply it to a series of span tags which are inside a div.

<div class="post"> <h2>{tag_postdate} <span class="topicName2"> </span></h2></div>

I need to get "News you can Use" and copy it inside each instance of .topicName2

Any help would be appreciated!

Upvotes: 0

Views: 99

Answers (1)

Felix Kling
Felix Kling

Reputation: 816810

Something like:

$('.topicName2').text($('#topicName').text());

Reference: .text()

Upvotes: 2

Related Questions