html - CSS style for NOT nested item -
i'm using css/sass style validity message. message not nested within i'm accessing.
for example javascript adds error class input box if it's not valid. want block visible attributes change further down page.
// when no error input#user_tags_attributes_0_tagname // div.tagname-available { display: block; } // not nested // , div.tagname-unavailable { display: none; } // not nested // when error input#user_tags_attributes_0_tagname.error // div.tagname-available { display: none; } // not nested // , div.tagname-unavailable { display: block; } // not nested
in theory should able access elements without having write javascript perform this. possibly if css has root document variable javascript's $(document)
do.
input#user_tags_attributes_0_tagname { $(document) > div.tagname-available { display: block; } // not nested $(document) > div.tagname-unavailable { display: none; } // not nested }
and html
<table> <tr> <td width="200px"> <span class="pull-right vf-labels">choose tag id</span> </td> <td> <input class="error" data-validate="/users/checktagname" id="user_tags_attributes_0_tagname" name="user[tags_attributes][0][tagname]" type="text"> </td> </tr> <tr> <td> </td> <td> <span class="text-primary" style="font-size: small;">check availability</span><br /> <div class="tagname-available"> <span class="glyphicon glyphicon-ok text-success" style="margin-left:-20px;margin-right:4px;"></span> <span class="text-success" style="font-size: small;">available</span> </div> <div class="tagname-unavailable"> <span class="glyphicon glyphicon-remove text-danger" style="margin-left:-20px;margin-right:4px;"></span> <span class="text-danger" style="font-size: small;">not available</span> </div> </td> </tr> </table>
possibly use :root
selector css?
you should able sibling selector.
// when no error input#user_tags_attributes_0_tagname + .tagname-available { display: block; } input#user_tags_attributes_0_tagname + .tagname-unavailable { display: none; } // when error input#user_tags_attributes_0_tagname.error + .tagname-available { display: none; } input#user_tags_attributes_0_tagname.error + .tagname-unavailable { display: block; }
Comments
Post a Comment