1

I am trying to get value of a input hidden field with an id like this

   leadConversionPage:leadConversionForm:pBConvertLead:pbSectionLeadSection:pbsiAccountName:accountLookup_lkid

I tried using

$("#leadConversionPage:leadConversionForm:pBConvertLead:pbSectionLeadSection:pbsiAccountName:accountLookup_lkid").val();

but thats throwing an error

Error: Syntax error, unrecognized expression: unsupported pseudo: leadConversionForm

I dont have control of how the id is been created. This is the way id is generated by salesforce

Prady
  • 10,978
  • 39
  • 124
  • 176

1 Answers1

3

You need to escape : with \\:. This is required because : is reserverd as it is used with selectors.

Try this:-

$("#leadConversionPage\\:leadConversionForm\\:pBConvertLead\\:pbSectionLeadSection\\:pbsiAccountName\\:accountLookup_lkid").val();

From Docs

To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \.

PSL
  • 123,204
  • 21
  • 253
  • 243
  • 2
    Yup. Right there. Article on it here: http://learn.jquery.com/using-jquery-core/faq/how-do-i-select-an-element-by-an-id-that-has-characters-used-in-css-notation/ – Phillip Berger May 23 '13 at 02:56