Reputation: 181
Not sure if I'm being too clear with the title. Sorry, it's late and I don't think I have a cleared mind.
Anyway what I want this to do is..
I'm able to do all of that, but it won't return to it's original position. I am a novice when it comes to jQuery, so this is where I ask for your help.
EDIT: The div manager doesn't seem to return to the old position. I've tried editing the css through jQuery to get it to, but it doesn't seem to work.
HTML :
<div id="manager">
<span>»</span>
</div>
<div id="managerp" style="">
</div>
No, I can't put managerp within manager, it doesn't seem to position itself as good as it should.
jQuery :
$(document).ready(function() {
$("#manager").click(function() {
$("#manager").css({'margin-left' : '270px', 'border-left' : '0'});
$("#managerp").toggle("slow", function() {
if ($("#managerp").is(':visible'))
$("span").html("«");
else
$("span").html("»");
});
});
});
This should help you get the picture of what it's supposed to look like. (Sorry if I am giving way too much information)
Thank you for your help. If you need me to be more specific as to what it should be doing, just ask.
Upvotes: 1
Views: 2653
Reputation: 21
Hope this helps ...
You need to reset Margin-Left to 0. Also hide the div ManagerP at the start.
<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#managerp").hide();
$("#manager").click(function() {
$("#managerp").toggle("slow", function() {
if ($("#managerp").is(':visible')){
$("span").html("«");
$("#manager").css({'margin-left' : '270px', 'border-left' : '01'}); }
else {
$("span").html("»");
$("#manager").css({'margin-left' : '0px', 'border-left' : '01'});}
});
});
});
</script>
<body>
<div id="manager">
<span>»</span>
</div>
<div id="managerp" style="">
This is a test for sliding control <br>
This is Manager P DIV
</div>
</body>
</html>
Apologies for bad formatting... working with notepad isn't fun
Upvotes: 0
Reputation: 94379
How about this:
$(document).ready(function() {
$("#manager").click(function() {
$("#managerp").toggle("slow", function() {
if($("#managerp").is(':visible')){
$("span").html("«");
$("#manager").css({'margin-left' : '0px', 'border-left' : '0'});
}else{
$("span").html("»");
$("#manager").css({'margin-left' : '270px', 'border-left' : '0'});
}
});
});
});
You have to reset the margin to 0px
.
Upvotes: 1
Reputation: 3939
IMO your problem is not to deal with jQuery.
the problem is you can't put the #manager and #managerp together as single element
try CSS absolute/relative position
Upvotes: 1
Reputation: 139
var flag = false;
$(document).ready(function() {
$("#manager").click(function() {
if(!flag)
{
$("#manager").css({'margin-left' : '270px', 'border-left' : '0'});
flag = true;
}
else
{
$("#manager").css({'margin-left' : '0px', 'border-left' : '0'});
flag = false;
}
$("#managerp").toggle("slow", function() {
if ($("#managerp").is(':visible'))
$("span").html("«");
else
$("span").html("»");
});
});
});
Upvotes: 1
Reputation: 3832
At first guess, there's no place in your code which actually resets the margin back. You're just resetting the text, but no margin back to zero. Am I missing something here?
Upvotes: 0
Reputation: 79041
Use multiple-selector on your code to manipulate multiple elements. Like this
$("#manager, #managerp").css({
'marginLeft' : '270px',
'borderLeft' : '0'
});
Upvotes: 0