Sailing_12
asked on
document.createElement missing self-closing slash
I notice that the code below generates IMG tags that have no self-closing slash. I think this may be keeping jQuery Thickbox from working correctly on my page images.
Anyone know how to force the / ?
Anyone know how to force the / ?
var image = document.createElement("img");
image.src = "images/events/shows/" + imagePath + "thumbs/" + imageNum + "_tn.jpg";
hyperlink.appendChild(image);
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think the self closing slash for IMG tag is not required when you use document.createElement
Re the first post, the tag name is img not image.
var imagesrc = "images/events/shows/" + imagePath + "thumbs/" + imageNum + "_tn.jpg";
$(hyperlink).append("<img src='" + imagesrc + "' />");
However, as far as I can tell, this should have no effect on whatever is causing Thickbox not to work.
In html (not xhtml), an img without self-closing tag is correct.
var imagesrc = "images/events/shows/" + imagePath + "thumbs/" + imageNum + "_tn.jpg";
$(hyperlink).append("<img src='" + imagesrc + "' />");
However, as far as I can tell, this should have no effect on whatever is causing Thickbox not to work.
In html (not xhtml), an img without self-closing tag is correct.
ASKER
Yes, the self-closing slash is not necessarily required by html standards, but it's the only thing I'm seeing different in my context between a hyperlinked image that works with thickbox, and one that doesn't. So I'm thinking that maybe jQuery/thickbox needs it to be there regardless of what standard we're coding to.
I haven't actually tested this theory with static markup code - I will do that tonight and report my findings. I guess I'd prefer not to have to include additional jQuery code just to add a slash, if it can be helped - seems to me the document.createElement ought to do this.
I haven't actually tested this theory with static markup code - I will do that tonight and report my findings. I guess I'd prefer not to have to include additional jQuery code just to add a slash, if it can be helped - seems to me the document.createElement ought to do this.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Static HTML works with thick box with or without the closing tag so that is apparently not the issue.
It seems that thickbox is having issue with the dynamically generated HTML.
It seems that thickbox is having issue with the dynamically generated HTML.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I found my own solution to the issue, but would like to award points to those that made helpful suggestions along the way. I did not want to use the 'accept multiple solutions' option as this would incorrectly log the wrong actual solution into my knowledgebase.
Thanks.
Thanks.
Thanks for the points!