日期:2014-05-17  浏览次数:20951 次

请问在JS里,如何让复选框左对齐?
我是用JS拼接成一个表格,由于是业务需要所以加上复选框,但是复选框因为后面数字而变的不整齐,请问如何让该复选框靠左对齐,有人说是用JS样式,但是我找不到。

JScript code
function init(array){
    var tableObj=document.getElementById("table");
    var t = tableObj.insertRow(0);
    t.width="800";
    t.height="8";
    t.align = "center";
    var  d_1=t.insertCell(0);
    d_1.width="100";
    d_1.height="18";
    d_1.innerHTML="序号";
    var d_2=t.insertCell(1);
    d_2.width="100";
    d_2.height="18";
    d_2.innerHTML="软件名称";
    var d_3=t.insertCell(2);
    d_3.width="100";
    d_3.height="18";
    d_3.innerHTML="软件分类";
    var d_4=t.insertCell(3);
    d_4.width="100";
    d_4.height="18";
    d_4.innerHTML="状态";
    var d_5=t.insertCell(4);
    d_5.width="100";
    d_5.height="18";
    d_5.innerHTML="下架时间";
    var d_6=t.insertCell(5);
    d_6.width="100";
    d_6.height="18";
    d_6.innerHTML="软件价格";
    var d_7=t.insertCell(6);
    d_7.width="100";
    d_7.height="18";
    d_7.innerHTML="软件存货";
    var d_8=t.insertCell(7);
    d_8.width="100";
    d_8.height="18";
    d_8.innerHTML="操作";
     for(var i=0;i<array.length;i++){
    var t_c= tableObj.insertRow(i+1);
        t_c.id="tr_"+array[i].id;
         t_c.width="800";
         t_c.height="18";
         t_c.align = "center";
         var dc_1 = t_c.insertCell(0);
         dc_1.width="100";
         
         dc_1.height="18";
         dc_1.innerHTML = "<input type='checkbox' ([size=14px][color=#FF0000]在这里插入的复选框[/color][/size]) id='"+array[i].id+"addButton'
value=array[i].goods_id/> &nbsp"+array[i].id;
         var dc_2 = t_c.insertCell(1);
         dc_2.width="100";
         dc_2.height="18";
         dc_2.innerHTML =array[i].title;
         var dc_3 = t_c.insertCell(2);
         dc_3.width="100";
         dc_3.height="18";
         dc_3.innerHTML = array[i].dic_name;
         var dc_4 =t_c.insertCell(3);
         dc_4.width="100";
         dc_4.height="18";
         dc_4.innerHTML = array[i].confirm_status;
         var dc_5=t_c.insertCell(4);
         dc_5.width="100";
         dc_5.height="18";
         dc_5.innerHTML = array[i].undercarriage_time;
         var dc_6=t_c.insertCell(5);
         dc_6.width="100";
         dc_6.height="18";
         dc_6.innerHTML  =array[i].sales_price;
         var dc_7=t_c.insertCell(6);
         dc_7.width="100";
         dc_7.height="18";
         dc_7.innerHTML  =array[i].stocknumber;
         if(array[i].confirm_status=="上架"){
             var dc_8=t_c.insertCell(7);
              dc_8.width="100";
              dc_8.height="18";
              dc_8.innerHTML="<a href=../mygoods/altermygoods.jsp?id="+array[i].id+">修改</a>"+" <a href='javascript:under("+array[i].id+")'  >&nbsp下架</a>"+"<a href='javascript:AddTo("+array[i].id+")'>&nbsp追加key</a>";

         }else{

              var dc_8=t_c.insertCell(7);
              dc_8.width="100";
              dc_8.height="18";
              dc_8.innerHTML="<a href=../mygoods/altermygoods.jsp?id="+array[i].id+">修改</a>"+" <a href='javascript:UpGoods("+array[i].id+")'  >&nbsp上架</a>"+"<a href='javascript:AddTo("+array[i].id+")'>&nbsp追加key</a>";

         }
         }
}