Say I'm have the code below and I would like to actived my button when somebody click on a car name, but I don't want to write every car name. I want to use the attribute "^=" that allows me to actived the button when somebody choose the car manufacturer ferrari, fiat or ford. In the CSS they existed the attribute "^=" witch I can use to define the first characters of names - in my example "f" for cars with the first characters. When I write this attribute in my jquery code the code doesn’t work. Have someone an idea who can I define the CSS attribute "^=" in this code below?
I tried to write in the code [value^="f"] but it dosen't work.
html
<select class="cars">
<option value="none" selected></option>
<option value="ferrari">Ferrari</option>
<option value="fiat">Fiat</option>
<option value="ford">Ford</option>
</select>
<button class="SubmitButton" type="button" >Click Me!</button>
css
.SubmitButton {width:150px;}
.ButtonColor1 {color:red;}
:disabled {
border:3px solid lightgray;
color:gray;
}
button {
border:3px solid green;
color:black;
}
button:hover:disabled {
cursor:not-allowed;
}
button:hover {
cursor:pointer;
}
jquery
$(document).ready(function() {
if($("select.cars").val() == "none"){
$(".SubmitButton").attr("disabled", "disabled");
}
$("select.cars").change(function(){
if($(this).val() == [value^="f"]){
$(".SubmitButton").removeAttr("disabled");
$(".SubmitButton").addClass("ButtonColor1");
}
else if($("select.cars").val() == "none"){
$(".SubmitButton").attr("disabled", "disabled");
}
});
});