Href is always "undefined"
In warning mode, I always get undefined ... why?
<script type="text/javascript">
$(document).ready(function(){
$("#menu ul li").click(function() {
var path = $(this).attr("href");
alert (path);
$.get(path, function(data) { $("#texte").html(data); });
return false;
});
});
</script>
</head>
<body>
<div id="wrapper">
<div id="menu">
<ul>
<li><a href="pulse/data/blocks/intro.html">Intro</a></li>
<li><a href="pulse/data/blocks/presentation.html">presentation</a></li>
<li><a href="pulse/data/blocks/pourquoi.html">pourquoi ?</a></li>
<li><a href="pulse/data/blocks/forfaits.html">forfaits</a></li>
</ul>
</div>
Your jQuery is referencing the wrong element: Instead of referencing the UL Li element, you need to reference the UL LI A element, as shown below:
$(document).ready(function(){
$("#menu ul li **a**").click(function() {
var path = $(this).attr("href");
alert (path);
$.get(path, function(data) { $("#texte").html(data); });
return false;
});
});