Did you insert the closing });?
21 Replies - 3262 Views - Last Post: 04 September 2011 - 10:21 AM
#16
Re: show/hide div elements in exact same position
Posted 04 September 2011 - 12:39 AM
#17
Re: show/hide div elements in exact same position
Posted 04 September 2011 - 12:45 AM
yes they are there, I just forgot to add them in my last post
#18
Re: show/hide div elements in exact same position
Posted 04 September 2011 - 12:46 AM
Ok, I will look into it. Give me some time, I must bathe and have lunch!
#19
Re: show/hide div elements in exact same position
Posted 04 September 2011 - 03:46 AM
No need to use $(element).wrap(), the following code will suffice:
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var sec = $("#second").html();
var fir = $("#first").html();
$("#second").remove();
$("button").click(function() {
if (this.id == "a") {
$("#content").empty();
$(fir).appendTo($("#content")); }
else {
$("#content").empty();
$(sec).appendTo($("#content")); }
});
});
</script>
</head>
<body>
<div id = 'container'>
<button id = "a">First!</button>
<button id = "b">Second!</button>
<div id = 'content'>
<div id = "first">
<p>I am first!</p>
</div>
<div id = "second">
<p>I am second!</p>
</div>
</div>
</div>
</body>
</html>
This post has been edited by cupidvogel: 04 September 2011 - 03:55 AM
#20
Re: show/hide div elements in exact same position
Posted 04 September 2011 - 10:17 AM
Works Thank you so much!! thanks for all your time you put into this.
This post has been edited by polska03: 04 September 2011 - 10:19 AM
#22
Re: show/hide div elements in exact same position
Posted 04 September 2011 - 10:21 AM
I simpyl copied and pasted and tried it out and then figured the source for jquery wasent a file I had, so I just used
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>your code is great, Thanks again so much!
|
|

New Topic/Question
Reply




MultiQuote



|