最近遇到這問題
搜尋一下
註記一下
https://stackoverflow.com/questions/6099301/dynamically-adding-html-form-field-using-jquery
$(function() {
// append input control at start of form
$("<input type='text' value='' />")
.attr("id", "myfieldid")
.attr("name", "myfieldid")
.prependTo("#form-0");
// OR
// append input control at end of form
$("<input type='text' value='' />")
.attr("id", "myfieldid")
.attr("name", "myfieldid")
.appendTo("#form-0");
// OR
// see .after() or .before() in the api.jquery.com library
});
意思就是jQuery 可以將HTML字串直接轉換成HTML物件
然後取得裡面的屬性
確實這樣做的情況不多
但是
寫程式嘛
什麼都會遇到![]()

留言板
歡迎留下建議與分享!希望一起交流!感恩!