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,306
  • 39
  • 123
  • 174

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
  • 122,084
  • 19
  • 250
  • 241