Jquery menu with less code
        Posted  
        
            by Sergio
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Sergio
        
        
        
        Published on 2010-05-10T10:11:36Z
        Indexed on 
            2010/05/10
            10:14 UTC
        
        
        Read the original article
        Hit count: 446
        
jQuery
I'm using Jquery for menu created like:
<div class="prof_info1">home</div><div class="prof_info2">info2</div><div class="prof_info3">info3</div>
And Jquery code like:
$(document).ready(function(){
$(".prof_info1").unbind("click").click(function(event) {
$("#main").html('<img src="img/spin.gif" class="spin">');
location.replace("?&id=<?=$id?>")
return false;
});
$(".prof_info2").unbind("click").click(function(event) {
$("#main").html('<img src="img/spin.gif" class="spin">');
$("#main").load('?a=2&id=<?=$id?>');
return false;
});
$(".prof_info3").unbind("click").click(function(event) {
$("#glavni").html('<img src="img/spin.gif" class="spin">');
$("#glavni").load('?a=3&id=<?=$id?>');
return false;
});
});
Is there any easier way to do write this Jquery code and make it with less code? Something like
if click somethind{
...
}elseif{
....}
© Stack Overflow or respective owner