2

How to use multiple different id with a variable of ID value? It don't show any error or output

function show_div(id)
{
    $("#edit_li"+id, "#save_li"+id).show();
}
1
  • you can debug using console.log Commented May 22, 2015 at 6:10

4 Answers 4

2
function show_div(id)
{
    $("#edit_tag"+id+",#save_li"+id).show();
}

The variable to be placed between + , while using within string.

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

Comments

1

Comma separate multi-selector, not as parameter

function show_div(id)
{
    $("#edit_tag"+id+ ",#save_li"+id).show();
    //               --^--
}

REF : Multiple-selector

Comments

1

You need to put , in selector as well as the comma outside mean you have two parameters in the selector instead of separating ids in selector.

$("#edit_tag"+id  ", #save_li"+id).show();

Comments

1

Always append and prepend your variables with + when they are in a string

function show_div(id)
    {
        $("#edit_tag"+id+",#save_li"+id).show();
    }

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.