This is not a ‘ attr()
vs prop()
’ question.
Consider having this so simple web form:
<form action="/">
<input type="radio" name="type" value="1" checked>
<input type="radio" name="type" value="2" >
<input type="radio" name="type" value="3" >
<input type="radio" name="type" value="4" >
<button type="submit"> Submit </button>
</form>
The very first radio button has checked
attribute as its default, and opening this web form brings up a well known picture:
Within a written jQuery script file, I'm trying to check a radio button - however it could be done using prop()
in a right and headache-less way, I went with attr()
.
Using browser's console, I'm able to check results immediately:
But I know I should uncheck all inputs before checking desired one to expect the correct result:
The argue begins here, when repeating the first step:
My question is why this happens? No check mark in radio button and in regards no value in server side.