Iterate through the class of a specific div that is inside another div

I have 2 divs with internal controls having class name .news-member-apps'. on the same page. Now I want Loop to say through the class name of a particular div that I want to skip through # div1, which has the class name .news-member-apps', and not another # div2. and get the value.

Note. Here I copy the contents of the DIV of the previous page into the current div page ie for example: in #PrevSelectedNews and scrolling through it.

var id = document.getElementById('<%=HiddenFieldNewsID.ClientID%>');
    $('#PrevSelectedNews').load("/Default.aspx #ScrollerDiv", function () {
                alert(id.value);
                alert('Load was performed.' + $('#PrevSelectedNews'));
               $(".news-member-apps").each(function (k) {
                    var NEWSID = $(this).attr("newsid");
                    var ID = $(this).attr("id");
                    if (NEWSID == id.value) {

                        $("#" + ID).appendTo("#SelectedNews");
                       alert($("#" + ID) + "Found! Appending");

                   }

               });

            });

#PrevSelectedNews . #PrevSelectedNews , .news-member-apps '. HiddenFiledNewID.value , "PrevSelectedNews", foind. ! !

+5
2

:

$('#PrevSelectedNews').find('.news-member-apps').each(function() { 
    // this - reference to each .news-member-apps item
})

"PrevSelectedNews" "news-members-apps" .

JQuery selector docs .

+8

Try

var id = document.getElementById('<%=HiddenFieldNewsID.ClientID%>');
$('#PrevSelectedNews').load("/Default.aspx #ScrollerDiv", function() {
    $(".news-member-apps", this).filter(function() {
        return $(this).attr("newsid") == id.value
    }).each(function(k) {
        $("#" + $(this).attr("id")).appendTo("#SelectedNews");
    });
});
+1

All Articles