I want change my class=\"value\"
on select option using jQuery
Example
I achieved this by storing the default class, and removing that class whenever the select changes.
var selectedScheme = 'Default';
$('#color_scheme').change(function(){
$('span').removeClass(selectedScheme).addClass($(this).val());
selectedScheme = $(this).val();
});
A working example can be found here: http://jsfiddle.net/9PeAc/1/
use the change
event to determine when the user selected another option. To remove all current classes, call removeClass()
with no arguments. Finally add the new class, which can be accessed by this.value.
$('#color_scheme').change(function(e) {
$('span').removeClass().addClass(this.value);
});
Demo: http://www.jsfiddle.net/4yUqL/100/
Try:
$('p').removeClass('myClass noClass').addClass('yourClass');