using variables in rel attribute in jquery and $.get function

312 Views Asked by At

i need a little help with this:

After loading a page i want to hide all submenus except the submenu for the loaded page. The information which submenue should not be closed stays in a php session…so I tried:

$.get("show-session.php", function(data){
    aktMenue =  data;   
    $(".dropmenue").next("ul:not([rel="+aktMenue+"])").hide();
    alert(aktMenue); 
    alert(data);
});  

But it doesn't work - even though the alerted variable “aktMenue” and “data” is correct (both “aName”).

So i tried this:

$.get("show-session.php", function(data){
    aktMenue =  data;   
    aktMenue = “aName”;
    $(".dropmenue").next("ul:not([rel="+aktMenue+"])").hide();
    alert(aktMenue); 
    alert(data);
});  

and this works … so why isn´t [aktMenue = data;] the same as [aktMenue = “aName”;] if alert(data) returns “aName” - and how can i use the [aktMenue = data;] variable within the rel attribute

Thanks in Advance.

1

There are 1 best solutions below

1
On

Add single quotes around the attribute value : $(".dropmenue").next("ul:not([rel='"+aktMenue+"'])").hide();