ตัวอย่างการเพิ่ม Item จากด้านบนของ Tag <ul>
โค๊ด HTML
1 2 3 4 5 6 7 |
<input type="button" value="Append" onclick="example_append()" /><br/> <ul> <LI>First Item</LI> <LI>Second Item</LI> <LI>Third Item</LI> <LI>Fourth Item</LI> </ul> |
โค๊ด Java Script
1 2 3 |
function example_append() { $("ul").prepend("<li>New Item is here</li>"); } |
ตัวอย่างการเพิ่ม Item จากด้านล่างของ Tag <ul>
โค๊ด HTML
1 2 3 4 5 6 7 |
<input type="button" value="Append" onclick="example_append()" /><br/> <ul id ="test"> <LI>First Item</LI> <LI>Second Item</LI> <LI>Third Item</LI> <LI>Fourth Item</LI> </ul> |
โค๊ด JavaScript
1 2 3 |
function example_append() { $("<li>new item this here</li>").appendTo("#test"); } |