0

In my JSF application,one of the html element having the below ID.

FrmOffer:rptOffer:0:j_idt325:0:j_idt355:0:j_idt356:0:j_idt560:0:j_idt632

When I try to select the element using below Jquery lines,

Option 1: $('#FrmOffer:rptOffer:0:j_idt325:0:j_idt355:0:j_idt356:0:j_idt560:0:j_idt632');

This returns : Uncaught Error: Syntax error, unrecognised expression: unsupported pseudo: rptOffer

Option 2:

$('#FrmOffer\\:rptOffer\\:0\\:j_idt325\\:0\\:j_idt355\\:0\\:j_idt356\\:0\\:j_idt560:0\\:j_idt632');

This returns: []

Can anyone advice how to select the element ?

Aravind
  • 1,145
  • 6
  • 18
  • 44

2 Answers2

0

That way you gonna suffer.

In jsf you can reffer to elements concatenating their parent element's name, if all the elements have an Id:

<h:form id="formId">
    <h:inputText id="emailAddresses" value="#{emailAddresses.emailAddressesStr}"/>

var input = document.getElementById('formId:emailAddress');

Maybe that answered question could help you How can I know the id of a JSF component so I can use in Javascript

Community
  • 1
  • 1
  • I already referred the link, but If I add ID to the parent element, the I have to modify the code of all the child elements. I don't want to break the functionality of such a complex for the sake of the one small change. – Aravind Mar 20 '17 at 03:14
0

We can use the native javascript selector instead of jquery. Below is my code:

document.getElementById('FrmOffer:rptOffer:0:j_idt325:0:j_idt355:0:j_idt356:0:j_idt560:0:j_idt632');
Aravind
  • 1,145
  • 6
  • 18
  • 44