javascript - Uncaught Error: Syntax error, unrecognized expression: unsupported pseudo: -
this question has answer here:
- how select jsf components using jquery? 3 answers
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
Post a Comment