This defines a complete css hook
Most people do not understand the knowledge points of this "so define a complete css hook" article, so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "so define a complete css hook" article.
To define a complete cssHook, we first need to test whether the version of jQuery you are using supports the cssHooks method, in addition, combined with the examples mentioned above:
(function ($) {
If (! $.cssHooks) {
Throw ("jQuery 1.4.3 + is needed for this plugin to work")
Return
}
Function styleSupport (prop) {
Var vendorProp, supportedProp
CapProp = prop.charAt (0) .toUpperCase () + prop.slice (1)
Prefixes = ["Moz", "Webkit", "O", "ms"]
Div = document.createElement ("div")
If (prop in div.style) {
SupportedProp = prop
} else {
For (var I = 0; I < prefixes.length; iTunes +) {
VendorProp = prefixes [I] + capProp
If (vendorProp in div.style) {
SupportedProp = vendorProp
Break
}
}
}
Div = null
$.support [prop] = supportedProp
Return supportedProp
}
Var borderRadius = styleSupport ("borderRadius")
/ / Set cssHooks only for browsers that
/ / support a vendor-prefixed border radius
If (borderRadius & & borderRadius! = = "borderRadius") {
$. CssHooks.borderRadius = {
Get: function (elem, computed, extra) {
Return $.css (elem, borderRadius)
}
Set: function (elem, value) {
Elem.style [borderRadius] = value
}
}
}
}) (jQuery)
You can then set the border radius using the DOM (hump) style or the CSS (hyphen) style in supported browsers:
("# element") .css ("borderRadius", "10px")
("# another") .css ("border-radius", "20px")
The above is about the content of this article "how to define a complete css hook". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.