Drag a table column to change the column width of the table (implemented by a Javascript script)

Source: Internet
Author: User
Drag a table column to change the column width of the table, and use JavaScript scripts to add it to favorites! See the following Code ... < Html >
< Head >
< Meta HTTP - Equiv = " Content-Type " Content = " Text/html; charset = gb2312 " >  
< Style >
. Resizedivclass
{
Position: relative;
Background-Color: red;
Width:2;
Z-Index:1;
Left: expression (This. Parentelement. offsetwidth-1);
Cursor: E-Resize;
}
</ Style >
< Script Language = Javascript >
Function Mousedowntoresize (OBJ) {
OBJ. mousedownx=Event. clientx;
OBJ. parenetdw=OBJ. parentelement. offsetwidth;
OBJ. parenetablew=Theobjtable. offsetwidth;
OBJ. setcapture ();
}
Function Mousemovetoresize (OBJ) {
If ( ! OBJ. mousedownx) Return   False ;
VaR Newwidth = OBJ. parenetdw * 1 + Event. clientx * 1 - OBJ. mousedownx;
If (Newwidth > 0 )
{
OBJ. parentelement. style. Width=Newwidth;
//Theobjtable. style. width = obj. parenetablew * 1 + event. clientx * 1-obj.mousedownx;
}
}
Function Mouseuptoresize (OBJ) {
OBJ. releasecapture ();
OBJ. mousedownx=0;
}
</ Script >
</ Head >
< Body >
Drag a table column to change the column width of the table.
< Table ID = Theobjtable Style = " Table-layout: fixed "   >
< Tr bgcolor = Cccccc >
< TD valign = Top >
< Font class = " Resizedivclass " Onmousedown = " Mousedowntoresize (this ); "  
Onmousemove = " Mousemovetoresize (this ); " Onmouseup = " Mouseuptoresize (this ); " > </ Font >
Column 1 </ TD >
< TD valign = Top >
< Font class = " Resizedivclass " Onmousedown = " Mousedowntoresize (this ); "  
Onmousemove = " Mousemovetoresize (this ); " Onmouseup = " Mouseuptoresize (this ); " > </ Font >
Column 2 </ TD >
< TD valign = Top >
< Font class = " Resizedivclass " Onmousedown = " Mousedowntoresize (this ); "  
Onmousemove = " Mousemovetoresize (this ); " Onmouseup = " Mouseuptoresize (this ); " > </ Font >
Column 3 </ TD >
</ Tr >
< Tr >
< TD > Drag a table column to change the column width of the table. </ TD > < TD > Drag a table column to change the column width of the table. </ TD > < TD > Drag a table column to change the column width of the table. </ TD >
</ Tr >
</ Table >
</ Body >
</ Html >


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.