Home > Back-end >  how to select option by default in a href
how to select option by default in a href

Time:10-23

<a href="#"  data-value="red-1" </span>"> 
<a href="#"  data-value="green-2" </span>">

i tried to add this but didn't work with a href

$(document).ready(function(){
    $('.image-swatch').prop('selectedIndex', 1);
});

image swatch is plugin for wordpress and have no selected by default option and my only way to do so by adding jquery so how i can select red by default using jQuery im not good when its come to coding thanks for your help

CodePudding user response:

Try this, just change the index in $colores[0], 0 is equal to the first element 1 the second and so on

jQuery(document).ready(function($){
  $colores = $('.image-swatch');
  $($colores[0]).addClass('selected');
});
  • Related