Reputation: 4122
If I'm appending multiple items in javascript like this:
data.context = $('<button class="btn btn-primary"/>').text('Upload')
.appendTo('#fileTableId')
.click(function () {
$(this).replaceWith($('<p id="aa"/>').text('Uploading...'));
data.submit();
});
How can I give each that is being replacedWith p tag a unique id if for example x++ is what I want to set it to.
var x = 0
'<p id = "'x'" />
x++;
Upvotes: 0
Views: 292
Reputation: 224857
You can use .prop
to set the id
property:
$(this).replaceWith($('<p>').prop('id', x).text('Uploading...'));
data.submit();
Upvotes: 2