Jquery version giving problems

Asked

Viewed 41 times

0

I’m in trouble because my site is done with Jquery 1.4.1.min and when I call a script like this:

<select  class="styledselect_pages" onchange="mudalinhas(this.value) ">  

Script with this version of jquery does not work:

  <script src="https://code.jquery.com/jquery-1.4.1.min.js"></script>

But with this version already works :

<script src="https://code.jquery.com/jquery-1.10.2.js"></script>

The problem with this version is that if I use it on my site it changes the site’s css

In other words my doubt is how I can use one of these versions that makes my script work and does not change my css styles.

My script :

<script src="https://code.jquery.com/jquery-1.4.1.js"></script>
<script type="text/javascript">
    function mudalinhas(idlinhas) {
        if (idlinhas == 5) {
            alert("ola");
        }
    }
</script>
  • The script you put up is independent of the jQuery version, in fact no jQuery is used in these lines. Two questions: #1: Why don’t you upgrade your code so you can use a newer version of jQuery? #2 what code runs most in this function if you can’t even upgrade from jQuery?

1 answer

0

Try using jQuery’s noConflict. Below is an example.

<script src="https://code.jquery.com/jquery-1.4.1.js"></script>
<script type="text/javascript">

    jQ = jQuery.noConflict();
    //Caso a sua classe styledselect_pages seja usada para instânciar algum plugin instâncie com o exemplo abaixo.

    jQ('.styledselect_pages').nome_do_plugin(); // jQ é usada para referenciar o jquery que você usou o noConflict;

    function mudalinhas(idlinhas) {
        if (idlinhas == 5) {
            alert("ola");
        }
    }
</script>

For more information https://api.jquery.com/jquery.noconflict/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.