Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×

is it possible to alter css of next sibling by 's value?

1535620168

Edited 1535620861
the following do not work: .charsheet select.sheet-select-stat-used[text='option3'] + span::before { content: "test"; } .charsheet select.sheet-select-stat-used[value='2'] + span::before { content: "test"; } .charsheet select.sheet-select-stat-used[slectedIndex='2'] + span::before { content: "test"; } (tried with and without ' and " around the value) the same type of thing of course works fine with checkbox:checked or radio:checked when it comes to ::before { content: "something here"; } and any other element's [attribute=value] + sibling { } works fine, can't seem to figure out how to use the select's value Is there any way to do this in the CSS? EDIT: This charsheet select.sheet-select-stat-used + span::before { content: "test"; } works fine. Just can't seem to figure out how use the value in it.
1535620901

Edited 1535620960
Jakob
Sheet Author
API Scripter
You cannot do it directly, since the value attribute is an attribute of the selected option, not the select itself. To do this, you will need another hidden input <select class="sheet-select-stat-used" name="attr_foo"> <option value="default" selected>Default</option> <option value="something_else">Not the default</option> ... </select> <input type="hidden" class="sheet-stat-used" name="attr_foo" value="default" /> <div class="sheet-test">Test!</div> Then you can use the value in CSS .sheet-stat-used[value="something_else"] + .sheet-test {color: red;} By the way, there's no need for the select and the input to the siblings in this example ... you could place the input, and hence the div (or span, or whatever), anywhere on your sheet and it would still work, as long as the attribute name agrees.
thanks!! didn't seem to want to work with just naming it, but adding a hidden inbetween disabled with value='@{select-stat_used}' (and giving the select an attr_select-stat_used name) worked!
1535623619
Jakob
Sheet Author
API Scripter
Freelance V. said: thanks!! didn't seem to want to work with just naming it, but adding a hidden inbetween disabled with value='@{select-stat_used}' (and giving the select an attr_select-stat_used name) worked! If I understood you correctly, this is definitely not the recommended way to do it, but I'm happy it works for you.