0

I have a peice of HTML that is being dynamically created from who knows where. Instead of tracking it down can I just run some jQuery to remove it? I want to delete all instances of:

<div style="clear:both"></div>
1
  • I would be careful removing that. You generally see that when you have elements with float:left or float:right. It allows the parent element of those floats to dynamically grow with them. Commented Jul 18, 2013 at 2:05

2 Answers 2

1

You could consider something like this:

$('div[style*=both]').remove();
Sign up to request clarification or add additional context in comments.

1 Comment

This seems like what I'd need but I can't get it to work: <div style="float:left;"> Hello </div> <div style="clear:both"></div> <div style="float:left;"> Hello </div> <script type="text/javascript"> $('#body div[style*=clear:both]').remove(); </script>
0
$("div").remove();

The above will remove all divs.

You might want to provide some more context, to limit the removal to this particular div though.

2 Comments

I would however attempt where the div originates from though since this is basically sweeping an unknown problem under the rug
Another consideration is that removing a "clear:both" element might have visual side effects if other elements are floating

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.