i am trying to highlighted selected radio button using Attribute Binding but i am not getting result can some one help me please
css
input:default {
box-shadow: 0 0 1px 1px red;
}
html
<input type="radio" name="gender" value="male" [attr.default]="value=='male'" (click)="value='male'"> Male<br>
<input type="radio" name="gender" value="female" [attr.default]="value=='female'" (click)="value='female'"> Female<br>
<input type="radio" name="gender" value="other" [attr.default]="value=='others'" (click)="value='other'"> Other
Below my stackblitz link
https://stackblitz.com/edit/angular-648y1w?file=src/app/app.component.html
asked Jan 16, 2019 at 8:41
Krish
4,25014 gold badges70 silver badges123 bronze badges
1 Answer 1
Your css selector is wrong
it should be like this
input[type="radio"][default="true"] {
box-shadow: 0 0 1px 1px red;
}
answered Jan 16, 2019 at 8:52
Just code
13.8k10 gold badges54 silver badges94 bronze badges
Sign up to request clarification or add additional context in comments.
4 Comments
Jonas Praem
demo links to this SO question
Krish
i have small doubt your saying my css is wrong but i followed this official link its working fine w3schools.com/cssref/sel_default.asp
Krish
can you please explain me ?
Just code
@Krish
The :default selector selects the default form element in a group of related elements. means when it renders and finds the radio checked on that element css will be applied, your case is of attribute not default selected.lang-js
but i am not getting result- So what is the problem? you do get 3 radio buttons, which is selectable.