On the page, we often use radio, such as sex: male, female, confidential.
But we don't like the default radio style! We'll replace it with something else.
My initial approach is to use the label display, set Radio to hide! (ie Display:none;)
When I click on the label, it also triggers the radio click event.
That is: ($ is jquery)
$ (". Label1"). Click (function () {
$ (". Radio1"). Click ();
Other code changes the style so that the label appears as (non) active
});
Firefox and Chrome are more normal, but IE has the next cup!
Further debugging, found that the original IE does not trigger the hidden elements of the event, that is, the style of "display:none;" The elements.
This time I think of jquery also has to implement this function Plug-ins! So I went to check the source code of the plug-in, nothing to find!
Then Firebug check CSS, finally, clip printed into my eyes.
Here, refer to the description on W3school: http://www.w3school.com.cn/css/pr_pos_clip.asp
Syntax: object.style.clip= "rect (0px,50px,50px,0px)"
The default value is auto
Four parameters, like other CSS styles, correspond to: top, right, bottom, left.
Based on the upper-left corner of the element positioning!
That is: (the distance between the upper and lower edges from the top, the left and right edges)
Top 0 from Upper boundary
Right edge 50 from left
Lower border from top 50
Left margin 0 to the left.
This is the range of 50x50 in the upper-left corner of the display element.
This CSS style works with the absolute positioning style, where the following two often appear together:
object.style.position= "Absolute";
object.style.clip= "rect (0px,50px,50px,0px)";
Back to our radio problem, we cannot set radio "Display:none;"
Instead, set
Position:absolute;
Clip:rect (1px, 1px, 1, 1px);
This time, radio is no longer hidden, but visible elements, but by cropping (clip), we actually can't see it, problem solved!