May 23, 2012, 09:07:38 AM
Pages: [1]   Go Down
  Send this topic  |  Print  
Share this topic on FacebookShare this topic on DiggShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter Topic: DIV Display Above Other DIV When Clicked via JQuery  (Read 701 times)
0 Members and 1 Guest are viewing this topic.
mikethedj4
Full Member
Resident Badass
*****

Reputation: +9/-1
Offline Offline

Posts: 548


Train Insane or Remain The Same


View Profile WWW
« on: April 28, 2011, 07:20:02 PM »

Here's the thing I wanna be able to click a div, and have it display above another div, on ever single div I have on my website I'm coding, (I also have it so I can click and drag divs as well) however I haven't had any luck.

For example if you head here - http://jsfiddle.net/e2TMV/

You can see that I made an example for you guys. I wanna be able to click and drag div1 and once it's clicked have it display above div2 and visa versa. As well as if I had 200+ divs on without a z-index applied to them via CSS.

This is the code I tried to achieve this effect, but didn't work.
Code:
$(function(){
$("div").click(function(){
$(this).css('z-index','2');
});
});
});
Logged







B.SkiLLs
Xtreme Administrator
Resident Badass
*****

Reputation: +56/-0
Offline Offline

Posts: 2365



View Profile WWW
« Reply #1 on: April 28, 2011, 07:40:02 PM »

uhm... not sure.. let me think about it but would have to have an: 'or else' statement in there somewhere.
Logged




mikethedj4
Full Member
Resident Badass
*****

Reputation: +9/-1
Offline Offline

Posts: 548


Train Insane or Remain The Same


View Profile WWW
« Reply #2 on: April 28, 2011, 08:35:38 PM »

I foundout how to do this. JQuery UI (which is what I'm using for clicking, and dragging the divs) has a stack option implemented in it, and I used that for this project.

Here's the code btw
Code:
$(function() {
$( "div" ).draggable({ stack: "div" })
});
Logged







B.SkiLLs
Xtreme Administrator
Resident Badass
*****

Reputation: +56/-0
Offline Offline

Posts: 2365



View Profile WWW
« Reply #3 on: April 28, 2011, 10:55:00 PM »

was also bout to say before you posted this ^^^ is that the sample you had already does it.. so how could you not know?

 Huh?
Logged




mikethedj4
Full Member
Resident Badass
*****

Reputation: +9/-1
Offline Offline

Posts: 548


Train Insane or Remain The Same


View Profile WWW
« Reply #4 on: May 01, 2011, 06:04:06 AM »

The sample has one div display above the current one, I wanted the bright gray one to display above the other once it was dragged.
Logged







B.SkiLLs
Xtreme Administrator
Resident Badass
*****

Reputation: +56/-0
Offline Offline

Posts: 2365



View Profile WWW
« Reply #5 on: May 01, 2011, 07:39:14 PM »

The sample has one div display above the current one, I wanted the bright gray one to display above the other once it was dragged.
it does, once they are clicked or re-clicked on after u drag/move them etc...
Logged




mikethedj4
Full Member
Resident Badass
*****

Reputation: +9/-1
Offline Offline

Posts: 548


Train Insane or Remain The Same


View Profile WWW
« Reply #6 on: May 02, 2011, 02:05:24 PM »

In the example it doesn't change the z-index of the div only enables it to click and drag.
Logged







B.SkiLLs
Xtreme Administrator
Resident Badass
*****

Reputation: +56/-0
Offline Offline

Posts: 2365



View Profile WWW
« Reply #7 on: May 03, 2011, 02:40:45 AM »

In the example it doesn't change the z-index of the div only enables it to click and drag.
Naw dude, it does change them. It has to, to even be able to be above the other one when being dragged bro.

Logged




mikethedj4
Full Member
Resident Badass
*****

Reputation: +9/-1
Offline Offline

Posts: 548


Train Insane or Remain The Same


View Profile WWW
« Reply #8 on: May 03, 2011, 02:53:11 AM »

This is what I was trying to accomplish when I posted the topic.

View this page first, and then this. Click and drag the divs, and you'll see what I mean.
Logged







B.SkiLLs
Xtreme Administrator
Resident Badass
*****

Reputation: +56/-0
Offline Offline

Posts: 2365



View Profile WWW
« Reply #9 on: May 03, 2011, 03:22:41 AM »

can't @ the moment. Real busy, gotta remind me.
Logged




B.SkiLLs
Xtreme Administrator
Resident Badass
*****

Reputation: +56/-0
Offline Offline

Posts: 2365



View Profile WWW
« Reply #10 on: May 04, 2011, 04:12:39 AM »

Mike, I hope your not stealing these things (like you use to do when you where litle younger) and then posting them here as tuts of your own that you created. I mean yeah can do tut on them if something you got from mains coding source somewhere else then learn it and want to write a tut but....

Anyways yes i just happen to find and come across quite a few like what you have posted last few days..

Such as this one might answer your question above here or your other post one.. Cant remember which it was about the div order being on top

Multi level popup with jQuery & css3

http://piroblog.pirolab.it/tutorials/popup/
Logged




mikethedj4
Full Member
Resident Badass
*****

Reputation: +9/-1
Offline Offline

Posts: 548


Train Insane or Remain The Same


View Profile WWW
« Reply #11 on: May 04, 2011, 06:52:37 PM »

I've been learning JQuery by messing around, and learning by their tutorials. I don't still shit anymore, that was back in like 2006 I have nothing to prove, all I've trying to do is get what I've learned, and share the knowledge to help others. As well as make cool effects for my website. If I haft to steal something to create an effect I feel it's asinine.
Logged







B.SkiLLs
Xtreme Administrator
Resident Badass
*****

Reputation: +56/-0
Offline Offline

Posts: 2365



View Profile WWW
« Reply #12 on: May 05, 2011, 11:38:55 PM »

ok well that's good & your learning seems great to & a good job so, that's why im saying that above plus as said come to something real close to what you did so double checking.

Logged




Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to: