Reputation: 3088
Sorry for real stupid question. But it does not work either way.
<html>
<head>
<script src='js/jquery.js' type='text/javascript'></script>
<script type='text/javascript'>
$(document).ready(function() {
var htmlcontent = $('.content').not('.dontgrab').html();
alert(htmlcontent); // returns EVERYTHING
});
</script>
</head>
<body>
<div class='content'>
BEFORE
<div class='dontgrab'>DON'T GRAB</div>
AFTER
</div>
</body>
</html>
Tried $(".content *:not('.dontgrab')").html(); // returns NULL
Please help.
Thanks.
Upvotes: 5
Views: 3467
Reputation: 3025
I think you are trying to do:
var htmlcontent = $('.content').remove(".dontgrab").html();
You could use .not() if the situation was like:
var htmlcontent = $('div').not(".dontgrab").html();
<body>
<div class="content">
BEFORE
AFTER
</div>
<div class="content dontgrab">DON'T GRAB</div>
</body>
I dont think you can use .not for selected elements children. I hope it helps
Upvotes: -1
Reputation: 35793
This should do it:
var clone = $('div.content').clone();
clone.find('.dontgrab').remove();
var html = clone.html();
Upvotes: 12