I have a code like this:
var formFocus = formFocus || {
spanElement: ".focusOnLoad form input[name="FirstName"]";
init: function () {
$(document).ready(function() {
//come other computation
$(formFocus.spanElement).focus();
});
},
};
I am running into issues with this line: spanElement: ".focusOnLoad form input[name="FirstName"]";
I get an error at name="FirstName"
I tried escaping " with spanElement: ".focusOnLoad form input[name=\"FirstName\"]";Then I get Unexpected token ; error.
I can get the code working if I just use .focusOnLoad form input[name="FirstName"] as selector. But I need to use a variable since ist a shared code and some others without the knowledge of this part has to use this variable.
Is there a way to fix this?
spanElement: ".focusOnLoad form input[name='FirstName']",;should be changed by,? You are enumerating members of an object, not statements.,after theinitproperty.