Reputation: 47
Can I remove a class property in html using jquery?
If the element is class = "item active"
on the next clone in jQuery how can I remove the active word?
Here's the Jquery Code
(function() {
$('#itemslider').carousel({
interval: 3000
});
}());
(function() {
$('.carousel-showmanymoveone .item').each(function() {
var itemToClone = $(this);
var allcase = $('#cases').val();
for (var i = 1; i < allcase - 1; i++) {
itemToClone = itemToClone.next();
if (!itemToClone.length) {
itemToClone = $(this).siblings(':first');
}
itemToClone.children(':first-child').clone()
.addClass("cloneditem-" + (i))
.appendTo($(this));
}
});
}());
Upvotes: 1
Views: 6782
Reputation: 2298
$("#your-element-id").removeClass('the-class-you-want-to-remove')
Example:
// Try to comment this line
$("#my-div").removeClass('active');
.active{
background-color: grey;
}
.blue{
color: blue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="my-div" class="item active blue">Hello, World!<div>
Upvotes: 0
Reputation: 223
you should use removeClass method
$(".active").removeClass("active");
Upvotes: 2
Reputation: 400
You can use the jQuery.attr function to set the new class.
jQuery('selector').attr('class', 'item');
Upvotes: 0