folks,
I have on my pages (http://playdota.thilisar.cz) a JavaScript file(code below), that has to have an effect of modyfying the edge of the icons(for real, it has to load new picture) and loading the information(only plain text so far) into a div with ID “info” on mouseover event;on mouseout event it has to load the original picture to same position. But it only writes informations and replaces icons with “[object Object]” text.
I hope, you understand this, because my english isn’t very good.
Thanks for your answers.
function showInfo(id){ //Using jQuery 1.7.2
document.getElementById('ses').innerHTML=$(function(){
$.ajax({
url: "sentinel_str/"+id+"-info.html"
}).done(function(data){
$("#info").html(data)
})
$("#ses").find("li").mouseover(function(){
$id=$(this).find("img").attr("id")
$(self.document[$id].src='look/icons/'+$id+'_hover.jpg')
})
$("#ses").find("li").mouseout(function(){
$id=$(this).find("img").attr("id")
$(self.document[$id].src='look/icons/'+$id+'.jpg')
})
})};
You’re getting
[object Object]because you’re setting the contents of an HTML element to ajQueryobject. If you want to call a piece of jQuery code, you don’t need to wrap it in$(). You can just call the code directly. So get rid of this line:and this line:
and the rest of your code will be executed when you call
showInfo(id).