css - On a hover event, change the content with data from the parent element -
i want hover pseudo element set child's content data parent (the hover). following snippet shows small test:
css
.word:hover { color: blue; } .word:hover ~ #lookup:after { content : attr(data-test); }
html
<span class="word" data-test="elke dag / 每天">everyday</span> <span class="word" data-test="ik / 我">i</span> <span class="word" data-test="drink / 喝">drink</span> <span class="word" data-test="koffie / 咖啡">coffee</span> <div id="lookup" data-test="duh!">lookup: </div>
however, content gets set data-test target 'duh!' instead of 1 being hovered over. can solve javascript, looking if possible using css only.
according mozilla docs, no: https://developer.mozilla.org/en-us/docs/web/css/attr
the attr() css expression used retrieve value of attribute of selected element , use in style sheet.
Comments
Post a Comment