0

I am trying to put stroke on any element with checked attribute but it is not working !


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Document</title>
<script type="text/javascript" src="jquery-2.1.1.min.js"></script>
<script type="text/javascript">
$("document").ready(function() {
     $("form:checked").css('border','1px solid red');
});
</script>
style type="text/css">
.a { color: Navy; }
.b { color: Maroon; }
</style>
</head>
<body>
<form>
<input type='radio' checked='checked'>Male
<input type='radio>Female
</form>
</body>


also this is not working: $("input:radio").css('border','1px solid red');

jess
  • 23
  • 7

1 Answers1

0

Due to the fact that a form does not have a "checked" attribute, you should change your jQuery selector to:

$("form").find(":checked").css('border','1px solid red');

This will select all checked elements underneath form.

marty
  • 4,005
  • 22
  • 19