使用jQuery FancyList我試圖插入一個<li>
通過代碼,而不是由用戶點擊行爲。填充列表從<a href="http://jquerywidgets.com/widgets/fancy-list/" rel="nofollow">http://jquerywidgets.com/widgets/fancy-list/</a></p> <p>動態
我的問題在於this
關鍵字,特別是以下行:
$(".fancy-list-footer .add").click(function() {
$('.tab-container .user-information .first-name:last').val('').removeClass('placeholder');
$('.tab-container .user-information .last-name:last').val('').removeClass('placeholder');
fancyList($(this));
});
我希望能夠通過一個姓和名,而無需填充文本框 - 一個for循環會做這個。
我試圖改變fancyList(elem)
功能fancyList(elem, firstName, lastName)
,但我似乎無法得到正確的值ELEM - 我想var elem = document.getElementByClassName('fancy-list-footer')
,因爲我認爲這就是在點擊按鈕提到的$(this)
,但是這也不能工作。
Codepen:http://codepen.io/anon/pen/vEYaqa?editors=101
任何幫助表示讚賞!