Welcome Guest, Not a member yet? Register   Sign In
Problems with jquery and ci
#1

[eluser]Unknown[/eluser]
Hi to everybody, I'm currently developing a dynamic menu system using jquery.

Here the code of the function jquery

http://jsfiddle.net/TEdcz/305/

But when i put the code on the view of the ci app the script doesn't work

Code of view

Code:
<ul id="n">
                        <li class="a-S">&lt;?php echo anchor('#soluzioni','SERVIZI' ,array('class'=>'buttons')) ?&gt;<span class="arw"></span></li>
                        <li>&lt;?php echo anchor('#come_funziona','COME FUNZIONA' ,array('class'=>'buttons')) ?&gt;</li>
                        <li>&lt;?php echo anchor('#prezzi','PREZZI' ,array('class'=>'buttons')) ?&gt;</li>
                       <li>&lt;?php echo anchor('#faq','FAQ' ,array('class'=>'buttons')) ?&gt;</li>
                       <li>&lt;?php echo anchor('welcome/contatti', 'CONTATTI'); ?&gt;</li>
                    </ul>

                
                [removed]
function toggleDiv(divId) {
    $('#'+divId).show("slow").siblings().hide("slow");
}


$('.buttons').click(function (e){
    e.preventDefault();
    var divId = $attr('href');

   toggleDiv(divId);
})

[removed]

<div id="soluzioni">Text</div>
<div id="come_funziona">Text</div>
<div id="prezzi">Text</div>
<div id="faq">Text</div>
#2

[eluser]Rolly1971[/eluser]
you should not need to call another function to toggle the div.

Code:
$(document).ready(function() {

    $('.buttons').click(function(){
        var divId = $attr('href');
        $('#'+divId).show("slow").siblings().hide("slow");
        return false;
    });

});




Theme © iAndrew 2016 - Forum software by © MyBB