I have a line of code as follows:
$('#type').val(target).trigger('change');
It opens a new div(it was display none). I want to run a code after that div opens and locates at DOM. How ca I do that?
You can create an event listener on that trigger just like you would any other native jQuery event.
//You can trigger it like you usually do or optionally pass in extra parameters in case you want your subscribed listeners to have access to that info
$('#type').val(target).trigger('change', param1, param2);
$('#type').live("change", function(event, param1, param2) {
$("#myDiv").show();
});
divis shown in response to thechangeevent. If thedivwasdisplay: noneand all you're doing is showing it, it's already in the DOM tree. It should appear near instantaneously, no need to wait. If my guess is incorrect, the question needs (much) more information.