Comunidad de diseño web y desarrollo en internet online

need help looding content into a div with jquery

Citar            
MensajeEscrito el 24 Abr 2012 11:11 pm
Hi there
I have trouble loding content ( what I am loading is a php file ) into a div. I am new in programming in general so I don t have a good command of most basic things.
I can load the content into a DIV when i use the same jquey ( or javascript ) code in a separate file but when I place it into the file I am interested, it won t work.

This is the link to the working document:
http://szler.com.ar/ejer/#content3

And this is the link to the file not loading it. and the one I am interested in making work ( the layout is different but I am using the same jquery file ). Here s the code:

$(function() {
$("#tabs a").click(function() {
var page = this.hash.substr(1);
<!--console.log(page);-->
$.get(page+" .php", function(gothtml) {

<!--console.log(gothtml);-->
$("#content").html(gothtml); });

return false;
});
});


And this is the html code of the one NOT working:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/JavaScript" src="javascript/1.js"></script>

</head>

<body>
<div id="header">
<div id="header_content">
<ul class="tabs" >
<li class="li"><a href="#content1">Tab 3</a> </li> <!--li= list item -->
<li class="li"><a href="#content2">Tab 2</a> </li>
<li class="li"><a href="#content3">Tab 1</a> </li>


</ul>
</div>

</div>

<div id="cuerpo">
<div id="content"></div>
</div>



</body>
</html>


Why does it work in one file and not in the other one ??? I would appreciate any help.
Thanks a lot

Por fabiuss

5 de clabLevel



 

firefox
Citar            
MensajeEscrito el 25 Abr 2012 12:22 pm
Because there is no html element with id="tabs". So onClick event never fires. I think you want this:

Código Javascript :

$(".tabs a").click(function() { // resto of the code...


See the dot instead of the hash?, because "tabs" is a class, not an id.

PS: Why you write in english?.

Por DriverOp

Claber

2510 de clabLevel



 

opera
Citar            
MensajeEscrito el 25 Abr 2012 05:37 pm
Thanks a lot, it was the "dot" issue as you put it.
Why do I write in English ??? No idea, I thought this was an English written forum and it doesn t make any difference to me whether it’s English or Spanish as long as I sort out programming related issues
Thanks

Por fabiuss

5 de clabLevel



 

chrome
Citar            
MensajeEscrito el 25 Abr 2012 08:55 pm
Pues no todo el mundo tiene por qué entender inglés en este foro aunque es cierto que en ninguna parte se prohiba escribir en otro idioma que no sea español...

Por DriverOp

Claber

2510 de clabLevel



 

opera
Citar            
MensajeEscrito el 25 Abr 2012 10:09 pm
Ah, ok, realmente pensé que era un foro en ingles, no sabia lo del español, disculpa, muchas gracias por la aclaracion

Por fabiuss

5 de clabLevel



 

chrome

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.