How to change ID after $.get()
How can I set the ID of a div after doing a $.get().
The point is to make it so that each piece that gets added using this function will have a uniqueID.
Everything I try seems to fail, I'm guessing its because the fragment of html that I am appending isn't in the document when i go to search for it.
I'm new to jQuery but I'm sure this isn't as hard as it seems.
- var uniqueCounter = 0;
- Add('Container.aspx', '#content'); //The default id of div from conatiner.aspx fragment is 'Container.aspx' for ease
- function Add(frag, location) {
- $.get(frag, function(data){$(location).append(data); }) //This part works
- .complete(function() {$('#' + frag).attr('id', frag + uniqueCounter);});
- uniqueCounter++;
- }
Or if there are better ways to do this I would love to know :) thanks