Add class is not working
Add class is not working
Hello friends i have three submit buttons.
and i want to add the class1 on the button which has the text 'a' by clicking on the button which has text
'Click me to add'.
But when i click this button it gives nothing.
Please help!
HtML--
<div>
<div>
<input type="submit" name="name" value="a" />
<input type="submit" name="name" value="b" />
<input type="submit" name="name" value="CLick me to add" id="Sub" />
</div>
</div>
CSS--
<style type="text/css">
input[type=submit] {
width: 60px;
height: 40px;
background-color:rgba(40, 35, 35, 0.84);
font-size:large;
color:white;
}
.class1 {
background-color:white;
}
</style>
Javascript--
<script type="text/javascript" src="jquery-1.11.1.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#Sub").click(function(){
var Mybutton = $(":submit").filter(function () {
if ($(this).val()=='a') {
return this;
}
});
$(Mybutton).addClass("class1");
});
});
</script>
Topic Participants
jakecigar