We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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.getAttribute(selectors) 讓所有 selector 一起 query,但是回傳的元素順序是按照 dom 順序排列,跟 selector 順序無關,所以 i18n 的值沒有照著 dom 上的 selector 順序排就會對應到錯的元素。
select.getAttribute(selectors)
html https://github.com/nics-tw/guide/blob/main/_components/form/index.md https://github.com/nics-tw/guide/blob/main/_includes/form/form-elements.html
js
guide/assets/js/main.js
Line 7 in e311f88
const selectors = ["[for=city]", "[for=id]"]; const i18n = { "[for=city]": "City of residence", "[for=id]": "ID type", }; selectors.forEach(selector => { const elements = document.querySelectorAll(selector); elements.forEach(element => { // Update the inner text with the i18n value element.textContent = i18n[selector]; }); });
The text was updated successfully, but these errors were encountered:
PR #39 嘗試暫時解決表單元件範例中,輸入欄位與多語言標籤排序不一致問題。
Sorry, something went wrong.
No branches or pull requests
Issue snapshot
Root cause
目前是用
select.getAttribute(selectors)
讓所有 selector 一起 query,但是回傳的元素順序是按照 dom 順序排列,跟 selector 順序無關,所以 i18n 的值沒有照著 dom 上的 selector 順序排就會對應到錯的元素。References
html
https://github.com/nics-tw/guide/blob/main/_components/form/index.md
https://github.com/nics-tw/guide/blob/main/_includes/form/form-elements.html
js
guide/assets/js/main.js
Line 7 in e311f88
Possible solutions
The text was updated successfully, but these errors were encountered: