0

I can only imagine that this has been asked several times, but I can't find it. Probably cus I'm searching with wrong words

Normally we can do this: id = $("#someId"); where the id is typically from a html control, looking like this: <input type="text" id="someId" />

But now the id will be passed with the function. So I want to do something like this:

function someFunct(id) {
    id = $("#"+id +");

How can I do this using js/JQuery?

3
  • 4
    Don't use the ending ") part, and you're good to go: $("#"+id); Commented Sep 23, 2014 at 9:31
  • Just fix your syntax error and it's correct. Commented Sep 23, 2014 at 9:31
  • what do you exactly want to do? Commented Sep 23, 2014 at 9:32

1 Answer 1

3
function someFunct(id) {
    id = $("#"+id +");

should be

function someFunct(id) {
    id = $("#"+ id);
Sign up to request clarification or add additional context in comments.

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.