0

This line $(''+fullId+'') is giving me problems. I've created an array in a different function that gets the #id's of all the inputs in the DOM.

Now with this function i'm trying to create a blur and focus jQuery function. I've set the variable fullId to prepend the '"#' and append the '"' to the variable name, but how do I get it to work?

$(''+fullId+'') is not doing the trick and neither does $(fullId)

function focusBlur () {
 var inputId = 0;
 var fullId = 0;
 for(var i=0; i<size; i++) {
 inputId = arr.shift();
 fullId = "\"#"+inputId+"\"";
 $(''+fullId+'').blur(function() {
 });
 $(''+fullId+'').focus(function() {
 });
 }
 }
asked Feb 3, 2010 at 3:00

4 Answers 4

1

Try $("#" + inputId)

answered Feb 3, 2010 at 3:07
Sign up to request clarification or add additional context in comments.

Comments

0

You don't need the double quotes. Just use:

fullId = "#" + inputId;

instead of:

fullId = "\"#"+inputId+"\"";
answered Feb 3, 2010 at 3:06

Comments

0

$(fullId).blur(function() {});

Ah, yeah, I missed adding the double-quotes. They're not necessary when the id is stored in a variable.

answered Feb 3, 2010 at 3:07

Comments

0

could you try

var fullId = "#"+inputId;
$(fullId).blur(function() {
 });
$(fullId).focus(function() {
 });
answered Feb 3, 2010 at 3:10

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.