/ Published in: JavaScript
Ever want to have content with rounded corners. One technique is to wrap the content inside 4 divs, but this can get messy. If you use prototype you can extend it with these. note the object notational style, build these into a return block!
Expand |
Embed | Plain Text
var Helpers = { wrap: function(element, tagName, newClassName){ element = $(element); var wrapper = document.createElement(tagName); element.parentNode.replaceChild(wrapper, element); wrapper.addClassName(newClassName); wrapper.appendChild(element); return Element.extend(wrapper); }, fourcorners: function (element, tag){ $w('ltc rtc lbc rbc').reverse().each(function(c){ element = element.wrap(tag,c) } ); return Element.extend(element); }, } Element.addMethods(Helpers);
You need to login to post a comment.
