How can I add a class to an existing li
with classes already assigned to it?
My current code is on http://jsfiddle.net/GbPdV/
I'm wanting to add the class of "Open" to:
< li class="dropdown hover carticon cart" >
I'm thinking that this has to happen inside of: (not sure)
if ( response.Status == "Success" )
{
$.ajax({
type: "GET",
url: "dmiajax.aspx?request=FloatingCart&extra=" + rnd(),
dataType: "html",
success: function(response) {
var floatingCart = $("ul.dropdown-menu.topcart");
if (floatingCart.length == 0) {
floatingCart = $('<ul class="dropdown-menu topcartopen"></ul>').insertBefore(".pull-right");
floatingCart.hoverIntent({
over: function() {},
timeout: 200,
out: function() {
$(this).stop(true, true).filter(":visible").hide("drop", {
direction: "down"
});
}
});
}
just use .addClass
floatingCart.addClass("Open");
success: function(response) {
var floatingCart = $("ul.dropdown-menu.topcart");
//HERE
floatingCart.addClass("Open");
if (floatingCart.length == 0) {
//OR HERE
floatingCart = $('<ul class="dropdown-menu topcartopen"></ul>')
.insertBefore(".pull-right")
.addClass("Open");;
floatingCart.hoverIntent({
over: function() {},
timeout: 200,
out: function() {
$(this).stop(true, true).filter(":visible").hide("drop", {
direction: "down"
});
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.