Reputation: 10068
I have div:
<div id="socialUserList">
//some content here, htmlTags, text, etc.
</div>
Now, I want everything inside of that div to be wiped out. I am trying this:
$("#socialUserList").innerHTML = '';
But for some reason it doesn't want to work. Why?
Upvotes: 3
Views: 87
Reputation:
The normal JavaScript method:
document.getElementById('socialUserList').innerHTML = '';
In jQuery:
$('#socialUserList').html('');
Pure JavaScript and jQuery go hand in hand, like so:
From pure JavaScript to jQuery:
var socialUserList = document.getElementById('socialUserList');
console.log($(socialUserList).html());
From jQuery to pure JavaScript:
var socialUserList = $('#socialUserList');
console.log(socialUserList[0].innerHTML);
Upvotes: 7
Reputation: 1363
Have you tried:
jQuery('#socialUserList').empty();
Note: You may have also tried this:
jQuery('@socialUserList')[0].innerHTML = '';
Using the [0]
will access the DOM object of the first matching element.
Upvotes: 1