Home › Forums › JavaScript › [Solved] Jquery switch view modes without refresh › Re: [Solved] Jquery switch view modes without refresh
January 25, 2011 at 4:41 am
#64084
jamygolden
Member
Hey Thierry,
PHP code is executed once a page is loaded, you’re not going to be able to include php loops within javascript.
What you could do is execute both loops within the page. So the one list will be ontop of the other list. You could then wrap both lists in a div, for example:
HTML:
Click here to switch between list and grid
// grid wordpress loop here
// list wordpress loop here
CSS:
#list{display: none;}
jQuery:
$(document).ready(function(){
$('#switch').click(function(){
$('#grid, #list').toggle();
});
});
By clicking on the anchor link, you will be hiding the grid and showing the list. When you click again, you will show the grid and hide the list – Which seems to be what you were looking for.