?
Solved

add image within div

Posted on 2014-04-14
6
Medium Priority
?
256 Views
Last Modified: 2014-04-29
this is how I want it to appear in my view.
<span class="stack88">
<div class="stack" id="stack">
<img stack="true" src="ImgN/myimage.jpg">
</div></span>

Open in new window


 also if I have multiply images then the div must stay the same
<span class="stack88">
<div class="stack" id="stack">
<img stack="true" src="ImgN/myimage.jpg">
<img stack="true" src="ImgN/myimage1.jpg">
<img stack="true" src="ImgN/myimage2.jpg">
</div></span>

 success: function (listItems) {
                            $.each(listItems, function () {
                            $(".stack88 img:last-child").remove()  // Remove last image before load.

                            $(".stack88").append($("<img>",
                            {
                                stack: "true",
                                src: "ImgN/" + this.myimage
                                
                            }));
                           
                        });

Open in new window

0
Comment
Question by:Seven price
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 1500 total points
ID: 39999537
What exactly is the problem you're having, and what is the html you're starting out with.

I think you should be appending the <img> to the #stack DIV, not the .stack88 SPAN. It also doesn't make sense to remove the last image and then append a new one - each time the loop runs it will remove the image it's just appended! If you want to remove the image before adding the new ones, then remove it before the loop:

$("#stack img:last-child").remove();
$.each(listItems, function () {
   $("#stack").append($("<img>", {
      stack: "true",
      src: "ImgN/" + this.myimage                                
   }));
});

Open in new window

It does depend on the data contained in listItems, so we may be able to help more if we see that.
0
 
LVL 9

Author Comment

by:Seven price
ID: 39999887
Its not going to work with that. Not for what I am trying to do. I need to to function the div then image then the closing div.  any other ideas my friend.
0
 
LVL 9

Author Comment

by:Seven price
ID: 39999911
Ok that will work.
0
Stressed Out?

Watch some penguins on the livecam!

 
LVL 9

Author Comment

by:Seven price
ID: 39999939
Ok that will work but let me explain the big picture and maybe you can guide me to the correct path.  

I am using a gallery.  if the image is static it loads correctly. when the css loads when I try to dynamically load the image onclick I need to the image and the css to appear. I guess it does not load correctly using onclick only when it first loads to the DOM. Need a work around, what do you think.?

<div id="stack" class="stack" style="background-image: url("images/backtexture.png"); background-color: transparent; width: 900px; height: 900px; float: none;">
<img src="ImgN/myimage.jpg" stack="true" style="width: 600px; height: 750px; z-index: 0; left: 331.5px; top: 189px; border: 5px solid rgb(255, 255, 255); box-shadow: 0px 0px 5px rgb(85, 85, 85);">
<div id="stackstkzoom" class="zoom" style="background-image: url("images/slidrogallery/nav/small/zoom.png"); left: 884.933px; top: 202.433px; z-index: 500;"> </div>
<p id="stackstkcaption0" class="stkcaption" style="margin-top: 0px; left: 336.5px; top: 874px; width: 600px; height: 70px; z-index: 999; display: none;">
<div id="stackstkrightarrow" class="stkrightarrow" style="z-index: 1800; background-image: url("images/slidrogallery/nav/small/right.png"); left: 966.5px; top: 514px;"> </div>
<div id="stackstkleftarrow" class="stkleftarrow" style="z-index: 1800; background-image: url("images/slidrogallery/nav/small/left.png"); left: 246.5px; top: 514px;"> </div>
<div id="stackstkzoom" class="zoom"> </div>
<p id="stackstkcaption0" class="stkcaption">
<span style="color: rgb(255, 255, 255); font-size: 1em; left: 300px; top: 35px;"> </span>
</p>

Open in new window

0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 40000458
Sorry, you've lost me - can't really figure out what you're trying to do? Can you try and explain again what you need.
0
 
LVL 9

Author Closing Comment

by:Seven price
ID: 40030500
tks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question