2010-01-22 29 views

回答

1

說不上什麼您的標記看起來像,但我會以爲這是symatic這樣的:

<ol id="ingredients"> 
    <li>1/4 cup of this</li> 
    <li>1 cup of that butter salad</li> 
</ol> 

你可以使用jQuery添加複選框寫下面的JavaScript:

$(document).ready(function() { 
    $('#ingredients li').prepend('<input type="checkbox" name="ingredients" />'); 
}); 

這會在文本前的列表中的每個LI內添加一個複選框。理想情況下,您應該像列出的那樣在列表中定義項目,這樣可以更容易地確定每個項目的內容。