Reputation: 7264
I have a simple js function:
function changeContent(id, content) {
$(id).html(content);
}
which gets called on ajax callback. id is an id of a div, and $(id) does indeed find it.
On Chrome I get an unhandled exception that HTMLDivElement doesn't contain method html(), while on IE8 and FF simply nothing happens, although when viewing in degub, .html() does appear in the dynamic method list.
What am I doing wrong?
EDIT: No, I'm not passing the id with #. I've tried that, it returned null, now it actually returns something. Is there another problem??
EDIT again: seems I was doing something else wrong. I've put the # back, now it works.
Upvotes: 0
Views: 213
Reputation: 4146
Are you passing simply the ID as a string? In which case I would think it's not truly being found, maybe try this?
function changeContent(id, content) {
$('#'+id).html(content);
}
Upvotes: 2
Reputation: 8407
Try use jQuery(id) instead.
You are sure you don´t pass the id without "#" right?
Upvotes: 3