dinesh
dinesh

Reputation: 1

How to select id in the div that was set by html()

$('#somediv').html(' <div id="innerDiv"> Testing </div>');

From the above statement I am setting the html for #somediv as

<div id="innerDiv"> Testing </div>

I want now to select innnerDiv. How do I do it??

eg: $('#innnerDiv').html("Modified");

Upvotes: 0

Views: 53

Answers (2)

Srikan
Srikan

Reputation: 2241

what ever you have stated $('#innnerDiv').html("Modified"); is the correct way to access the #innerdiv and modify its content

Upvotes: 0

Ibu
Ibu

Reputation: 43850

Just the way you did it, once the html is on the DOM you can select it

$('#innnerDiv')

if you want the html inside, you can use:

var htmlStr = $('#innnerDiv').html();
// in your case it will contain: Testing

Upvotes: 1

Related Questions