$("#mainMenu").children('li').eq(0).children('a').bind({
click : function() {
Here I’m clearing blocks aside and section. And dynamically creating them by appending worksParser();.
$('aside > *').remove();
$('section > *').remove();
worksParser();
And here I want to call function fromAsideToSection. And send dom element $('aside').children('.workExample') just appended to block aside.
var x = $('aside').children('.workExample');
alert(x);
fromAsideToSection.call(x);
But x return (object object), instead of (object HtmlDivElement). How I can send (object HtmlDivElement) to function?
}
});
function worksParser() {
$.ajax({
type : "GET",
url : "base.xml",
dataType : "xml",
success : function(xml) {
$(xml).find('siteExample').each(function() {
var name_dump = $(this).attr('name');
var mediaType_dump = $(this).attr('mediaType');
var media_dump = $(this).attr('media');
var video_dump = $(this).text();
var description_dump = $(this).attr('description');
var url_dump = $(this).attr('url');
if (mediaType_dump != 'video') {
$('aside').append('<div class="workExample"><div class="mediaName">' + name_dump + '</div><div class="exampleMedia"><img src="' + media_dump + '" alt="" /></div><div class="descrExample" style="display: none">' + description_dump + '</div><div class="urlExample" style="display: none">' + url_dump + '</div></div><div class="separator"></div>');
} else {
$('aside').append('<div class="workExample"><div class="mediaName">' + name_dump + '</div><div class="exampleMedia"><img src="' + media_dump + '" alt="" /></div><div class="descrExample" style="display: none">' + description_dump + '</div><div class="videoExample" style="display: none">' + video_dump + '</div></div><div class="separator"></div>');
}
});
}
});
}
function fromAsideToSection() {
alert(this);
if ($(this).children('.videoExample').length > 0) {
$('section > *').remove();
$('section').append('<div id="mediaName" class="mediaName">' + $(this).children(".mediaName").text() + '</div><div id="mediaBlock"></div><div id="mediaMore">Описание</div><div id="mediaDescription">' + $(this).children('.descrExample').text() + '</div>');
$('section').children('#mediaBlock').append($(this).children(".videoExample").children().clone("withDataAndEvents, deepWithDataAndEvents"));
} else {
$('section > *').remove();
$('section').append('<div id="mediaName" class="mediaName">' + $(this).children(".mediaName").text() + '</div><div id="mediaBlock"><a target="_blank" style="" href="' + $(this).children('.exampleMedia').children('img').attr('src') + '"> <img src=' + $(this).children('.exampleMedia').children('img').attr('src') + ' alt="1.jpg"></a></div><div id="mediaMore">Описание</div><div id="mediaDescription">' + $(this).children('.descrExample').text() + '</div>');
}
sectHeight = null;
oldHeight = null;
sectHeight = $('section').height();
$('aside').height(sectHeight);
}
This sounds like a job for .get() *
simple fiddle based on your submission
Buuut, your function
fromAsideToSection(which is cut-off by the way) is using$(this)so if this is an element or a jQuery object it doesn’t matter — jQuery will recognize it and$(this)will end up being essentially the same thing whetherthisis a jQuery object or the DOM elements. I stressed that in the fiddle.*Not to be confused with the ajax shorthand jQuery.get() ref: api.jquery.com/jQuery.get/