javascript - Uncaught Error: Syntax error, unrecognized expression: unsupported pseudo: -


this question has answer here:

i have txtbox , id : begindatetxt

but jsf makes j_idt8:begindatetxt

in jquery try reach that

  <script type="text/javascript">             $(document).ready(function() {                 $(function() {                     $("#j_idt8:begindatetxt").mobiscroll().date({                        theme: 'android-ics light', mode:'scroller', display: 'bottom'                     });                 });              });    </script> 

but below error:

uncaught error: syntax error, unrecognized expression: unsupported pseudo: begindatetxt

why?

you try

$(document.getelementbyid('j_idt8:begindatetxt')).mobiscroll().date({theme: 'android-ics light', mode:'scroller', display: 'bottom'}); 

in general jquery uses css selectors in $() function. in css selector : denotes pseudo-class. however, in case : part of id.

if use generic getelementbyid(), argument not decomposed, seen id altogether. using getelementbyid() , wrapping result $() can circumvent "misunderstanding".

in general, however, think better change namespacing scheme in jsf.

edit

the jquery documentation on selectors states should escape special characters use of \\:

to use of meta-characters ( such !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) literal part of name, must escaped with 2 backslashes: \. example, element id="foo.bar", can use selector $("#foo\\.bar").

this lead answer given daniel, in opinion superior answer given above. explanation, however, remains valid.

$("#j_idt8\\:begindatetxt").mobiscroll().date({theme: 'android-ics light', mode:'scroller', display: 'bottom'}); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -