Todd Penland
asked on
jQuery to Add Image from XML File
I've just about got this working (with the help of others here). I'm new at using jQuery so please be patient. Here's what I'm trying to do.
I have the URL for three images within <image> tags in my XML file (attached). I now want to use jQuery to insert these images into my HTML page. I know I need to set both the 'class' and the 'src' attributes in here somewhere but I can't quite manage to make it work. I know the jQuery in my .js file (attached) is wrong however it works fine until it gets to inserting the images. Any help? Thanks!
pbkpluscom-jquerytest.html
pbkpluscom-jquerytest.xml
pbkpluscom-jquerytest.css
pbkpluscom-jquerytest.js
I have the URL for three images within <image> tags in my XML file (attached). I now want to use jQuery to insert these images into my HTML page. I know I need to set both the 'class' and the 'src' attributes in here somewhere but I can't quite manage to make it work. I know the jQuery in my .js file (attached) is wrong however it works fine until it gets to inserting the images. Any help? Thanks!
pbkpluscom-jquerytest.html
pbkpluscom-jquerytest.xml
pbkpluscom-jquerytest.css
pbkpluscom-jquerytest.js
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the .appendTo should reference an element but you've specified "content", which I can only find in the xml. this should be an element in your html, not the xml, such as "body"out another element such as a div with an ID. e.g. .appendTo("div#idhere")
$('<img class='imgfloatr'>').html(
needs to be
$("<img class='imgfloatr' src='+$('image', this).html() +'>").appendTo('content');