开发者

JQuery script not working despite working in the console

I am attempting to make the entire div of a Nivo slider on this site clickable so the visitor can navigate to a featured article. I developed the following script within Chrome's console to work out the bugs.

var $j = jQuery.noConflict();

$j(function(){      
    $j( '.nivo-slice' ).click(function(){
        window.location = $j('.nivo-html-caption').find('a:first').attr('href');
    });
});

This script开发者_开发知识库 works perfectly when entered via the console, however when inserted into a js file (custom.js) and included in the footer, it doesn't work at all. If you view the page source, the file shows up correctly in the markup and Chrome's inspector flags no errors. I'm confused, anyone have ideas?

Thanks!


Well, the error that i see in the console

Chrome gives:[jquery.form] terminating; zero elements found by selector

Comes from this line

$('div.wpcf7 > form').ajaxForm

This is located in your scripts.js file. It cant find div.wpcf7 > form hence, throws that error.

As far as your code goes, i don't see an element with class .nivo-slice.


There is no argument for the delay:

when you call the slider. It is just blank. It needs a value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜