go to url if div has certain bg image
I'm trying to check if a div has a certain background image, and if it has the image, then the page should navigate to a url.
However, I can't get it to work, what am I doing wrong?
case key.enter:
    if (letterIndex == 0 && $(this).hasClass('active')) {
           $(this).prev().remove();
    } else if ($('.content').css("background-image") === "url(img/screen-check.jpg)") { 
            // go to url
    }  else {
            $(this).closest('li').toggleClass('active');
    }
    break;
Not sure if below code works. Please try and let me know
 case key.enter:
        if (letterIndex == 0 && $(this).hasClass('active')) {
               $(this).prev().remove();
        } else if ($('.content').css("background-image") &&$('.content').css("background-image").indexOf('img/screen-check.jpg') >-1 ) { 
                // go to url
        }  else {
                $(this).closest('li').toggleClass('active');
        }
        break;
上一篇: 如何从JavaScript列表中访问网站
下一篇: 如果div具有某些bg图像,请转到url
