Following is html code of two pages where in one page i have written data-filter attribute which i need to apply in other html page. The way i have done it's not working.
<div class="grid_12" id="category-nav">
<ul id="category" class="list-of-links centered">
<li><a href="otherpage.html" class="current-cat" data-filter="rondvaart">Rondvaart</a></li>
<li><a href="otherpage.html" data-filter="wandelingen">Wandelingen</a></li>
<li><a href="otherpage.html" data-filter="rondleidingen">Rondleidingen</a></li>
<li><a href="otherpage.html" data-filter="groepsarrangementen">Groepsarrangementen</a></li>
</ul>
The HTML code for otherpage.html is
<article class="post" data-cat="wandelingen">
<header>
<p class="byline">Rondvaart</p>
<h2>Binnendieze</h2>
</header><!-- End header -->
</article><!-- End article.post -->
<article class="post" data-cat="rondleidingen">
<header>
<p class="byline">Rondvaart</p>
<h2>Binnendieze</h2>
</header><!-- End header -->
<article class="post" data-cat="wandelingen">
<header>
<p class="byline">Rondvaart</p>
<h2>Binnendieze</h2>
</header><!-- End header -->
Javascript/Jquery is:
var posts = $('.post');
posts.hide();
$( "#category li a" ).click(function() {
var customType = $( this ).data('filter');
console.log(customType);
console.log(posts.length);
posts
.hide()
.filter(function () {
return $(this).data('cat') === customType;
})
.show();
});
customTypefromvar customType = $( this ).data('filter');?