5

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

2 Answers 2

6

i think you wanted to write

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

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

Sign up to request clarification or add additional context in comments.

1 Comment

not to be a stickler, but you should accept the answer if it was the solution for you.
3

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

+ will concatenate strings.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.