Reputation: 583
so I am using Jquery to try and get a href link with a data variable that represents a div to load in an class called tile-are-main... it doesn't seem to be working though...
<script type="text/javascript">
$(function(){
$(".submenu-who.nav-container a").click(function(e){
e.preventDefault();
var url = $(this).attr('href') + ' #' + $(this).attr('data-target');
$('.tile-area-main').load(url);
});
});
</script>
this is the menu with the href in it ...
<body class="metro">
<div class="submenu-who">
<header class='masthead'>
<div class='brand-container'>
<a href='#'>
<span class='brand-initials'>Who Are Musability?</span>
<span><i class="fa fa-briefcase brand-initials-icon"></i></span>
</a>
</div>
<nav>
<div class='nav-container'>
<div>
<a class='slide' href='#' data-target='mission'>
<span class='element'>Mission and Values</span>
</a>
</div>
it is the a href with the data'mission' bit that refers to a div of text that i want into tile-area-main.. to keep it simple.
I think that I am missing out the classes between submenu-who and the a so in theory if i just add them all in with a space between each one that should work ?
Upvotes: 2
Views: 368
Reputation: 1896
Yes, you need to add a space in between. The space is basically meant for all the children inside it, while no space between two classes is used when both the classes are applied to same element.
$(".submenu-who .nav-container a").click(function(e){
e.preventDefault();
var url = $(this).attr('href') + ' #' + $(this).attr('data-target');
$('.tile-area-main').load(url);
});
Upvotes: 1