2013-02-04 39 views

回答

0

只需添加的HTML标记,复选框内<span> 试试这个

.html("<span> <input type='checkbox' value='value' />test<input type='checkbox' value='value1' />test1</span >") ;   
1

.html()有几个问题与串联:

.html("<span>" "</span >" + " <span>""</span> ")  
    //------^^^^--------------------^^--------useless quotes are here. 

这样:

.html("<span></span ><input type='checkbox' value='' />" + " <span>""</span> ") 

这样:

.html("<span></span >" + " <span></span><input type='checkbox' value='' />") 

或后两个:

.html("<span></span> <input type='checkbox' value='' />" + " <span></span><input type='checkbox' value='' />") 
0

您也可以使用html选项。

var $a = $("<a/>", { 
    "data-transition": "slide", 
    "html": $("<input>", { 
    "type": "checkbox" 
    }) 
}) 
.appendTo(li); 

,它将使这个HTML:

<a data-transition="slide"><input type="checkbox"></a>