保留2个选定项目

问题描述 投票:0回答:1

我想在我的网站上添加带有按钮的选择器,如图片。我已经成功完成一个带有以下代码的按钮。但是我想保持第一选择并选择第二个按钮。对不起我的英语,我不知道您是否理解我,我发现这个网站实际上正在按照我的意愿进行。

如果能帮助我,请先谢谢您。enter image description here

$(function($){

  var $go = 'test1';
  var $notgo = 'test2';

  $('.romain-test-btn').each( function(){

  $(this).click( function(){

    $('.romain-test-retour').fadeIn();

    if (($(this).attr('id') == 1 ) || ($(this).attr('id') == 3 )){

     $('.romain-test-retour').html( $go );

        }else{


           $('.romain-test-retour').html( $notgo );

        }

    $('.romain-test-btn').fadeOut();




  });

  });

 });

jquery
1个回答
0
投票

我不明白你的意思。但我认为问题在于您的查询选择$('.romain-test-retour')。当按类别名称选择时,选择了该类别且功能html的所有要素都将应用于所有这些元素。您需要更改查询,例如按ID选择。

© www.soinside.com 2019 - 2024. All rights reserved.