当前位置: 动力学知识库 > 问答 > 编程问答 >

internet explorer 7 - jQuery, .wrap and click in IE7

问题描述:

I have a problem in IE7 using jQuery's .wrap function. I have a list of elements. On click I do something like this:

function wlt(father) {

hlms = $(father).find('.moreSpan a').attr('href');

tlms = $(father).find('.moreSpan a').attr('title');

// Add/remove link on h2

$(father).find('h2 > .bold').wrap('<a></a>');

$('.stripClose h2 > a > .bold').unwrap();

$(father).find('h2 > .bold').wrap('<a href="' + hlms + '" title="' + tlms + '"class="searchtitle_i"></a>');

// Add/remove link on Showcase H2

$(father).find('h2 > .linkAllTitle ').wrap('<a></a>');

$('.stripClose h2 > a > .linkAllTitle').unwrap();

$(father).find('h2 > .linkAllTitle ').wrap('<a href="' + hlms + '" title="' + tlms + '"class="searchtitle_i"></a>');

}

Basically in each web browser this code works: it displays the content of a div and adds a link to the li element clicked.

In IE7 when I click on the li element the page displays the content of the div and then goes to the link added by jQuery. Do you have an idea of what's going on?

网友答案:

It sounds like your click event is continuing to propagate or maybe a mouse button up event is triggering the link. Is it possible to call the wlt function like so?

$(father).click(function(event) {
     event.stopPropagation(); 
     function wlt(father);
     }
分享给朋友:
您可能感兴趣的文章:
随机阅读: