In JavaScript, you set the floating properties of elements (float), and standard browsers use CSS tutorials to float,ie older versions using Stylefloat. This uses $ (xx). CSS ("Cssfloat", "right") or $ (xx). CSS ("stylefloat", "right") all browsers are OK
jquery's CSS method unifies two kinds of writing, uses the float attribute directly, the following CSS method passes the parameter "float" to be able to set up also can obtain the element float.
<div id= "D1" >float div</div>
<script type= "text/web Effects" >
$ (' #d1 '). css (' float ', ' right ');
var str = $ (' #d1 '). css (' float ');
alert (str);
</script>
But jquery has to be smart, plus support for cssfloat and stylefloat, see API documentation, like getting the float property of an element, the following is equivalent.
1 $ (' Div.left '). css (' float ');
2 $ (' Div.left '). CSS (' cssfloat ');
3 $ (' Div.left '). CSS (' stylefloat ');
But mode 3 returns different values in each browser, such as using stylefloat to get floating
<div id= "D1" >float div</div>
<script type= "Text/javascript" >
Alert ($ (' #d1 '). CSS (' stylefloat ');
</script>
IE6/7/8: Setup was unsuccessful
Ie9/10/firefox/safari/chrome/opera: Set Success
Also, use stylefloat to set the float:
<div id= "D1" >float div</div>
<script type= "Text/javascript" >
$ (' #d1 '). CSS (' stylefloat ', ' right ');
</script>
This uses $ (xx). CSS ("stylefloat") there is no compatibility problem.
2, modify the Jquery.style method, add a judgment if Stylefloat or cssfloat are converted to float
Don ' t set styles on text and comment nodes
if (!elem | | elem.nodetype = = 3 | | elem.nodetype = 8 | |!elem.style) {
Return
}
This is the plus fix code.
if (name = = = "Cssfloat" | | | name = = "Stylefloat") {
name = "float"
}
//Make sure T Hat we ' re working with the right name
var ret, type, OrigName = jquery.camelcase (name),
style = ELEM.S Tyle, hooks = jquery.csshooks[OrigName];