У меня есть некоторые проблемы с этим кодом, я хочу судить, если у div next().children() нет длины, тогда требуется ajax. Но это всегда требует ajax, даже если у div есть контент.
Вот HTML-код:
.more{display:none;}
View more
Relative post
View more
Relative post
Вот код jquery:
jQuery(document).ready(function(){
$(".click").live('click',function() {
if($(this).next('.more').is(':visible')){
$(this).next('.more').css('display','none');
}else{
$(this).next('.more').css('display','block');
}
if($(this).next('.more').children('.relative-post:has(*)').length){
}else{
var $this = $(this);
var item_id = $this.attr('rel');
$.ajax({
url: "process",
dataType: "html",
type: 'POST',
data: 'post=' + item_id,
cache: false,
success: function(data){
$this.next('.more').children('.relative-post').html(data);
}
});
}
}
});
});
Подробнее здесь: https://stackoverflow.com/questions/122 ... query-code