Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select ID start with number is not a valid selector #1333

Closed
ewwink opened this issue Jan 29, 2018 · 3 comments
Closed

select ID start with number is not a valid selector #1333

ewwink opened this issue Jan 29, 2018 · 3 comments

Comments

@ewwink
Copy link

ewwink commented Jan 29, 2018

<div id="123id">
  <p>hello</p>
</div>
<script>
var aa = $('#123id p').html();
console.log(aa);
</script>

SyntaxError: '#123id p' is not a valid selector
but jQuery is fine.

@fangbinwei
Copy link

zepto use document.querySelectorAll('#123id p') to select the element node, and querySelectorAll needs valid CSS selectors.

However, it seems that ID selectors are not allowed to start with a number.
<style> #123id {background-color: red; }</style> doesn't work either.

https://css-tricks.com/ids-cannot-start-with-a-number/

I hope it can help you.

@shirenhu
Copy link

but you can use document.getElementById to select the element

@madrobby
Copy link
Owner

Please fix your IDs to conform to the HTML standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants