Reputation: 4819
I have a div tag:
<div id="content"><p></p><a href="#"></a></div>
I want to insert dynamically different content into the <p>
tag and also into the href attribute of the <a>
tag.
I am using jQuery.
Upvotes: 0
Views: 172
Reputation: 145408
As easy as:
$("#content > p").html("Some content");
$("#content > a").prop("href", "/new/link.html");
Or in chain:
$("#content")
.find("p").html("Some content")
.end()
.find("a").prop("href", "/new/link.html");
Upvotes: 4