Append a string to the end of an element attribute using jQuery
- by ILMV
I have an element:
<select id="row" />
I want to append a string to the end of the id attribute, like this:
<select id="row_1" />
The jQuery I am using to achieve this is (from within an each):
$(this).attr('id',$(this).attr('id')+'_'+row_count);
This looks ugly as sin, and whilst it works I want to know if there is a simpler solution. In this example, the ID prefix (e.g. row) is never constant, so I can't just do 'row_'+row_count.
Cheers!