JQuery - Adding selectors dynamically not working
<p>I have a div window that pops up in the center of the screen. Within this window there is two custom generically created checkbox's and a button when clicked makes an ajax request that sends the checked value from the custom made checkbox control.</p>

<h2>HERE IS THE CHECKBOX CONTROL</h2>

<pre><code>function CreateGenericCheckBox(text, groupname, checked) {


    var divCheckBoxContainer = $("&lt;div/&gt;");
    $(divCheckBoxContainer).attr("class", "divcategorycheckboxcontainer");

    var divCategoryContainer = $("&lt;div/&gt;");
    $(divCheckBoxContainer).append(divCategoryContainer);
    $(divCategoryContainer).attr("class", "divcateogrycheckobex");
    $(divCategoryContainer).addClass(groupname);
    $(divCategoryContainer).attr("onclick", "ClickGenericCheckBoxByGroupName(this,'" + groupname + "')")

    if (checked) {

        var divCategoryTickContainer = $("&lt;div/&gt;");
        $(divCategoryContainer).append(divCategoryTickContainer);
        $(divCategoryTickContainer).attr("class", "divcateogrycheckobextick");
    }

    var divCategoryText = $("&lt;div/&gt;");
    $(divCheckBoxContainer).append(divCategoryText);
    $(divCategoryText).attr("class", "divchannelcateorytext");
    $(divCategoryText).text(text);

    return $(divCheckBoxContainer);

}
</code></pre>

<h2>HERE IS WHEN I WANT TO GET THE CHECKBOX VALUE</h2>

<pre><code>function GetGenericCheckBoxValue(name) {

    $("div." + name).children("div").each(function() {

        var tick = $(this);

        if ($(tick).length &gt; 0) {

            var parent = $(this).parent();
            var textDiv = $(parent).next();

            return $(textDiv).text();

        }

    });

     return "";
}
</code></pre>

<h2>HERE IS THE WINDOW CREATION</h2>

<pre><code>function DialogWindowDragMediaItems(userPageType, imageParams, idParams) {


    idParams = idParams.replace(/~/g,"|")

    var divBGContainer = $("&lt;div/&gt;");
    var lengthVideos = imageParams.split("~").length - 1;


    var divInfoText1 = $("&lt;div/&gt;"); ;
    $(divBGContainer).append(divInfoText1);
    $(divInfoText1).text("What would you like to do with the videos selected?");
    $(divInfoText1).attr("class","videosselecteddraginfo");

    $(divBGContainer).append(CreateGenericCheckBox("Move and Copy", "copymedia", true));
    $(divBGContainer).append(CreateGenericCheckBox("Move and Delete", "copymedia", false));

    var buttonMove = GetDialogWindowButton("Move Items", "DestroyDialogWindowHideTransparent('DialogWindowDragMediaItemsAddID'); WebForm_DoCallback('MainPageControl1','dragmediatomedia~" + userPageType + "~" + idParams + "~' + GetGenericCheckBoxValue('copymedia'),null,null,null,true)");

    CreateGenericWindowDialog($(divBGContainer), "DialogWindowDragMediaItemsAddID", 500, "images/mainpage/dialogwindow/titleimageaddmedia.png", "Move Items", "Cancel", buttonMove, true);





}
</code></pre>

<p>So when i want to get the checkbox value using GetGenericCheckBoxValue('copymedia') the selector does not find the 'copymedia' selector, the length is 0 but i have done $(div).addClass('copymedia') dynamically when the checkbox is created and appended to the div window. So why isnt the selector being found?</p>
