Geeks With Blogs
Paolo del Mundo Senior Consultant at Excella Consulting
Today I was faced with an unusual task: I needed to find a way to nullify an element's style attribute, i.e.:

<br style="clear: both">

The style's clear:both was causing some unnecessary whitespace. I couldn't change the style attribute directly because it was on a Master page that I didn't have the permission to modify.

I am not sure if there is a way to do this using CSS alone (element style takes precedence over any css class).

My Solution

Step 1: Hide the offending <br> element

// br[style] matches any <br> that has an attribute style
br[style]
{
     display: none;
}


Step 2: Add a regular <br> element after document has loaded

<script language="javascript">
$(document).ready (function() {
    $('br[style]').after('<br>');
});
</script>

Basically I'm hiding the problematic <br> element and replacing it with another <br> without the "clear: both baggage".

So jQuery saves the day! However, I'd be very interested if anyone knew of a better solution to this problem... perhaps there is a CSS trick I don't know about? Posted on Tuesday, February 10, 2009 11:43 PM | Back to top


Comments on this post: DOM Manipulation with jQuery

# DOM Manipulation with jQuery
Requesting Gravatar...
I’ve been using jQuery for only two or three weeks now at most, and I’ve just been breezing through making all kinds of new xml-grabbing features - For this project management courses helpful.Its developing XML for all this stuff now, in preparation for expanding jQuery’s use into just about everything!

Although this article is simple, I think that MANY people will benefit from it. One of the first things people seem to do with jQuery is either sorting lists or tables, and that is an extremely nice thing to be able to do in such an easy way. Its also beneficial for Clay pigeon shooting games.

When I was using normal Javascript, I kept seeing all this stuff about jQuery, didn’t feel like downloading and installing something new, all the while I was just frustrating myself on simple tasks again and again. Well I can say that I strongly recommend anyone who has their own website, especially a complex one, should get jQuery - it’s easy as heck. God is it easy! I feel like such a bonehead only just having installed it a few weeks ago! I should have been using it since its first release. Oh well, gotta learn sometime. :)
Left by Allen on Nov 04, 2009 3:38 AM

# re: DOM Manipulation with jQuery
Requesting Gravatar...
I didn't try it.. but
maybe something like this could work:
br[style='clear: both']{clear:none}

or just:
br{clear:none}
Left by ng on Feb 04, 2010 2:16 PM

# re: DOM Manipulation with jQuery
Requesting Gravatar...
I kept seeing all this being about j Query, didn’t feel like downloading and installing something new, all the while I was just arresting myself on simple tasks afresh and again. Able-bodied I can say that I acerbic acclaim anyone who has their own website, abnormally a circuitous one, should get j Query - it’s simple as heck. God is it easy! I feel like such a blockhead alone just accepting installed it a few weeks ago! I should accept been application it back its aboriginal release. Oh well, gotta apprentice sometime. :
---------------------------------
android code
Left by Allen on Mar 15, 2010 2:43 AM

# re: DOM Manipulation with jQuery
Requesting Gravatar...
Very nice posting in this site. This is a very interested information about this topic. I really very exited your blog here. kept seeing all this getting about j Query, didn’t feel like downloading and installing something new, all the while I was just arresting myself on simple tasks afresh and again. Able-bodied I can say that I acerbic acclamation anyone who has their own website, abnormally a circuitous one, should get j Query - it’s simple as heck. God is it easy! I feel like such a blockhead abandoned just accepting installed it a few weeks ago!
Left by bratny on May 12, 2010 1:24 AM

# re: DOM Manipulation with jQuery
Requesting Gravatar...
All of your the cipher that you actualize should be included in it’s own bearding function. This ensures that the jQuery variables are local: your capricious declarations will not breach the jQuery library, and the jQuery library will not overwrite your variables, methods and properties.

For our own javascript, we are traveling to abbreviate all our cipher in an bearding function. However, back we are accessing elements of the DOM, we charge to ensure that the DOM is loaded. Tech Web We can’t use the departure at the end as in the cipher above, which executes the bearding action immediately, back our DOM isn’t loaded yet. We should alone assassinate our bearding action already we accept the DOM. After jQuery, and after abundant Javascript skill, the accepted avenue is to cover a document.onLoad event.
Left by Jsmeen on May 12, 2010 1:31 AM

# re: DOM Manipulation with jQuery
Requesting Gravatar...
ery nice posting in this site. This is a very interested information about this topic. I really very exited your blog here. kept seeing all this getting about j Query, didn’t feel like downloading and installing something new, all the while I was just arresting myself on simple tasks afresh and again. Able-bodied I can say that I acerbic acclamation anyone who has their own website, abnormally a circuitous one, should get j Query - it’s simple as heck. God is it easy! I feel like such a blockhead abandoned just accepting installed it a few weeks ago! You can get Islamic Information and also Technology Information.
Left by mubeen on May 29, 2010 8:19 PM

Your comment:
 (will show your gravatar)


Copyright © Paolo del Mundo | Powered by: GeeksWithBlogs.net