How to set outerHTML with jQuery

0 votes

I have a UserControl. Ex:

<div id="divItem">
some html
</div>

The ajax request return new html of this UC from server. Ex:

<div id="divItem">
    new html
</div>

I want to replace the old html by the new one. How could I do that?

Apr 27, 2020 in Java-Script by kartik
• 37,520 points
2,447 views

1 answer to this question.

0 votes

hello @kartik,

This is innterHTML because it's inside the div called divItem. It also looks like you want to replace the existing text (?)

If your returned new html is in a variable called results, you do this:

$('#divItem').html(results);

Thank You!!

answered Apr 27, 2020 by Niroj
• 82,840 points

Related Questions In Java-Script

0 votes
1 answer

How to send data in request body with a GET when using jQuery $.ajax()?

Hello @kartik, Sending the data in your scenario,I ...READ MORE

answered Jun 18, 2020 in Java-Script by Niroj
• 82,840 points
19,644 views
0 votes
1 answer

How to set cookie value with AJAX request?

Hello @kartik, Basically, ajax request as well as ...READ MORE

answered Jun 18, 2020 in Java-Script by Niroj
• 82,840 points
46,078 views
0 votes
1 answer

How to change an element's ID with jQuery?

Hello @kartik, Your syntax is incorrect, you should ...READ MORE

answered Aug 25, 2020 in Java-Script by Niroj
• 82,840 points
3,960 views
0 votes
1 answer

How to Change the selected value of a drop-down list with jQuery?

Hello @kartik, With hidden field you need to ...READ MORE

answered Sep 9, 2020 in Java-Script by Niroj
• 82,840 points
2,898 views
+1 vote
1 answer

What is the relationship between angularjs Scope with controller/view?

Let us consider the below block: <div ng-controller="emp"> ...READ MORE

answered Jan 20, 2020 in Web Development by Niroj
• 82,840 points

edited Jan 21, 2020 by Niroj 1,191 views
0 votes
1 answer

What is data binding in AngularJS?

Data binding is synchronization of data between the ...READ MORE

answered Jan 23, 2020 in Web Development by Niroj
• 82,840 points
1,154 views
0 votes
1 answer

How can we avoid my php form from hacking?

Hii @kartik, If you want to know php ...READ MORE

answered Feb 13, 2020 in PHP by Niroj
• 82,840 points
2,613 views
0 votes
1 answer

How can you display the error messages?

Hey, In the HTML form, we add ...READ MORE

answered Feb 13, 2020 in PHP by Niroj
• 82,840 points
3,523 views
0 votes
1 answer

How to set “checked” for a checkbox with jQuery?

Hello @kartik, Use: $(".myCheckbox").attr('checked', true); // Deprecated $(".myCheckbox").prop('checked', true); And if ...READ MORE

answered Aug 28, 2020 in Java-Script by Niroj
• 82,840 points
6,239 views
0 votes
1 answer

How to call jQuery UI Dialog with ASP.NET button postback?

Hello @kartik, To solve the problem with ASP:Button ...READ MORE

answered Apr 28, 2020 in Java-Script by Niroj
• 82,840 points
3,679 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP