0

My IDE is throwing a unique warning.

the jQuery code is :

var $xcol = $("#xcol");
var $ycol = $("#ycol");
var $filtercol = $("#filtercol");

$filtercol.on('change', function(event, params) {
        // can now use params.selected and params.deselected
        var value;
        var text;
        if (params.selected){
            value =  params.selected;
            $("#xcol option[value='"+value+"']").remove();
            $("#ycol option[value='"+value+"']").remove();
            $xcol.trigger("chosen:updated");
            $ycol.trigger("chosen:updated");
        }
        else if (params.deselected){
            value =  params.deselected;
            text = $("#filtercol option[value='"+value+"']").text()
            $xcol.append('<option value="'+ value +'">'+ text +'</option>');
            $ycol.append('<option value="'+ value +'">'+ text +'</option>');
            $xcol.trigger("chosen:updated");
            $ycol.trigger("chosen:updated");
        }

    });

the warning is flagged on this line of code:

 $("#xcol option[value='"+value+"']").remove();

How can I fix this warning? THANKS!

enter image description here

2
  • Consider using the .find() method against $filterCol rather than using the selector. idea reference
    – Forty3
    Commented Apr 6, 2017 at 3:12
  • 1
    What does the "more..." link tell you?
    – nnnnnn
    Commented Apr 6, 2017 at 3:22

1 Answer 1

0

One quick way is to not add many selectors when leading with an ID:

$("#xcol option[value='"+value+"']").remove();
$("#filtercol option[value='"+value+"']").text()

to

$("#xcol").find("option[value='"+value+"']").remove(); 
$("#filtercol").find("option[value='"+value+"']").text()
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.