tags:

views:

149

answers:

2

I am a nOOb to jQuery.

I want to use variables in jQuery to hide/show divs.

what I have so far is:

$(document).ready(function(){
    $('#listMenu a').click(function () {
            var getPage = $(this).attr("id");
            var getName = $(this).attr("name");
            //console.log(getPage);
            //console.log(getName);

            $("#" & getName ).show();



    });
});

firebug console shows that I have the vars correctly, but I get this error next:

this[H].style is undefined [Break on this error] (function(){var R=/((?:((?:([^()]+)...typeof K==="string"?K:K+"px")}})})();

any help is appreciated. sjs

+3  A: 

i think you wanted to write

$("#" + getName ).show();

& is not an operator in javascript, but + is.

mkoryak
Resolved.Thank you, that was the issue.
ussteele
not to be a stickler, but you should accept the answer if it was the solution for you.
mkoryak
+1  A: 

use $("#" + getName ).show();

+ will concatenate strings.

antpaw