I have a function that adds a div to another div.
Sort of:
var div = ...some html
$("#mydiv").append(div);
However, I want to add something to the div I just added. Currently, I want to hide the sub-item of the new div and add the object as data. Sort of
var div = ...some html
$("#mydiv").append(div);
$(my new div).find(".subDiv").hide();
$(my new div).data('user',object);
But how do I get the new div that I created? Is there a way to create it and then preform these actions and then add it? Or should I add it and then extract it and change it?
Efficiency is important as it will be repeated for search results ...
Thank!
I used this as my solution thanks to Tricker:
var div = ...a lagre piece of html;
var newDiv = $(div);
newDiv.find("[show='contractor']").hide();
newDiv.data('user', userObject);
$(appendDiv).append(newDiv);
Thank!
source
share