A simple JavaScript / jQuery way of swapping the positioning of two image links on click? -


i have set client-side translation of web page using translate.js. if user clicks on say, french, move position of english , english move position of french. tried following:

$('.img-btn').click(function(){      var clickedid = $(this).attr('src');      alert('you clicked on button #' + clickedid);      $('.img-btn.active').attr('src', clickedid);  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>  <div id="language-select">          <a class="lang_selector trn" href="#" role="button" data-value="fr"><img id="french" class="img-fluid rounded-circle img-btn" src="img/flags/fr.jpg" alt="french"></a>          <a class="lang_selector trn" href="#" role="button" data-value="it"><img id="italian" class="img-fluid rounded-circle img-btn" src="img/flags/it.jpg" alt="italian"></a>          <a class="lang_selector trn" href="#" role="button" data-value="en"><img id="english" class="img-fluid rounded-circle img-btn active" src="img/flags/en.jpg" alt="english"></a>          <i class="fa fa-angle-right fa-2x" aria-hidden="true">      </div>

but doesn't seem work (not alert did). ideas?

good afternoon,

i think want this:

    $('.lang_selector').click(function(){       var clickedid = $(this).children(':first').attr('src');       alert('you clicked on button #' + clickedid);        var lastchild = $('div#language-select > i:last-child');       var lastlink = $('div#language-select > a:last-of-type');        //insert current clicked element last position       lastchild.before($(this));        //insert element last before first element       $('div#language-select > a:first-of-type').before(lastlink);      }); 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -