开发者

Click Event not binding?

I have a menu, I'm trying to change the background image of a div elsewhere in the html to the href of the link clicked. It's odd because i have a script that does almost the same thing, on mouseover. I tried to tweak it to work for this, but to no avail.

    $(".IG_Nav_List a").live('click',function(){ 
        var src = $(this).attr("href");
        $('.Background').css('background-image', 'url(' + src + ')'); 
    });

    ////////////////

   <div class="Background"></div>

    <ul class="IG_Nav_List">
   开发者_如何学编程    <li><a href="Surface/A.jpg" onclick="return false;">AAAA</a></li>
       <li><a href="Surface/B.jpg" onclick="return false;">BBBB</a></li>
       <li><a href="Surface/C.jpg" onclick="return false;">CCCC</a></li>
    </ul>


for starters:

'url(+src+)'

should probably be

'url('+src+')'


I don't see the element with the Background class but..

Here's a catch:

$('.Background').css('background-image', 'url(+src+)'); 

should be

$('.Background').css('background-image', 'url(' + src + ')');


For the first part of your code, look at this line:

$('.Background').css('background-image', 'url(+src+)'); 

This should be

$('.Background').css('background-image', 'url(' + src + ')'); 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜