$.get(DL+"a=ts&q="+Q,function(data){
$('.load').html(data);
});
The data returned from $.get is loaded into the .load class. There are two portions of the data returned. The first being, a Nth number of numbers in a single UL.
<ul><li class="num id0"...
The second, a Nth number of UL(s) with a class of id0 - Nth number.
<ul class="list id0"...
Once the data has been loaded in to class .load,
$(document).on('click','.num',function(){
var ID = $(this).attr('class');
ID = ID.split(' ');
ID = ID[1];
alert(ID);
$('.list').css('display','none');
$('.list .'+ID).css('display','inherit');
});
An alert with the correct ID is alerted. However, the .list .idX is not made visible.
I am guessing it is b/c it is not available to the DOM. So, my question, either how do I make it available, or how do I use .on('not click','.list',function().. to do what I need - or what do I need to do to make this work?
You should not be using the descendant selector:
$('.list.'+ID)
// ^^ no space
This will select all elements with class list
and class <whatever-ID-refers-to>
, instead of selecting all element with class <whatever-ID-refers-to>
who are descendants of .list
.
I also recommend to not encode the list IDs in CSS classes, use data-*
attributes.