简体   繁体   中英

Javascript/jQuery regex for “border-radius” value

I'm using jQuery corner plugin for border-radius cross-browser support. This is my function:

if(!Modernizr.borderradius){ 
    var s = document.styleSheets;
    for(var i = 0; i<s.length;i++){ 
        var r = s[i].rules || s[i].cssRules;
        for(var x=0;x<r.length;x++) {
            var t = r[x].cssText || r[x].style.cssText;
            if(t.search("radius")>0) $(r[x].selectorText).corner();
        }
    }
}

Basically, i'm retrieving any element who has border-radius set.

I need a better regex, like this one:

border(-)?(top|bottom)?(-)?(left|right)?-radius:(.+?);

to detect any variation of border-radius and retrieve its value. Thanks a lot

我想您正在寻找...

\bborder(?:-(?:top|bottom))?(?:-(?:left|right))?-radius\s*:\s*([^;"']*)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM