中添加Data-test-id屬性到我有Table
,Textarea
和Button
。當Textarea
內的用戶類型,然後點擊我的Button
文本被添加到Table
作爲行與下面的代碼:在我的Jquery
<script type="text/javascript">
$(function() {
$('#CustomButton').click(function() {
$('#CustomPickedTable tbody').append(
$('<tr/>',
{
click: function() {
$(this).remove();
},
html: $('<td/>', {
text: $('#CustomQuestionText').val()
})
})
);
return false;
});
});
</script>
當TextArea
內的用戶類型,然後點擊該Button
是我的Table Tbody
得到這個<td>What user typed..</td>
我想什麼是我的表得到<td data-test-id="5">what user typed..</td>.
是否有任何解決方案,在我的jQuery所以我<td>
得到的數據測試-id屬性?
在此先感謝!
我不能'使用click:function(){ $(這)一個.remove(); – Obsivus 2012-03-29 08:39:12
@RammtinAvar,查看我的更新 – Starx 2012-03-29 08:56:53
+1 for fiddle ... – diEcho 2012-03-29 08:58:02