Wrap Your HRs for Easy Stylin'


/ Published in: jQuery
Save to your folder(s)

HRs are a pain in the ass to style, so why bother? Wrap them in a DIV with a class of HR instead. (In your stylesheet, set .hr hr { display: none }).

This also ports the class of the HR up to the new parent DIV, allowing you to make a few different HR types that clients can easily work with.


Copy this code and paste it in your HTML
  1. $("hr").each(function() {
  2. var hrClass = jQuery(this).attr("class")
  3. $(this).wrap("<div class='hr " + hrClass +"'></div>");
  4. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.