简体   繁体   中英

Migrating scripts from 1.7.1 to 1.9 jQuery (Bootstrap 3)

I have javascript scripts that work with jQuery 1.7.1, but don't with 1.11.1 that comes with Bootstrap v3.3.4

The code is across three scripts, but here is one part that toggles rows in a table:

$('#change-selection').click(function(e){
    e.preventDefault();
    $('.product-choice').toggle();
    $(this).toggleClass('closed');
});


$('.compare th a').click(function(e){   
     e.preventDefault();
    var className='tr.'+$(this).parent().attr('class');

    $(className).toggle();
    $(this).toggleClass('closed');
});

If I link the page to jQuery 1.7.1, toggling across the HTML table works, CSS works as well, but Bootstrap dropdown navigation stops working (fair enough, Bootstrap requires a higher jQuery version). If I use the jQuery that came with Bootstrap, toggling across the HTML table stops working, and CSS inside the table gets messed up. The code above should be a good start to fix the toggling at least. I read about what got deprecated with jQuery 1.9, but that was not enough for me to fix this. I replaced that one instance of attr with prop, but that did not make any change. Is this code troubling for that toggling function or I should look elsewhere?

Thank you

If you got to have, you can have 2 or more versions of jQuery on the same page. https://forum.jquery.com/topic/multiple-versions-of-jquery-on-the-same-page

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM