2

I have function to get radio button value.

var val = $('input[name="test_'+ id + 
'"]:checked').val();

but it cause DOM XSS. How do I refactor to prevent XSS?

thanks.

john chen
  • 77
  • 6

1 Answers1

1

This does not have an XSS vulnerability except in extremely ancient versions of jQuery, so it's probably not something to worry about.

Avoiding jQuery and using querySelector will work though.

const val = document.querySelector('input[name="test_'+ id + '"]:checked').value;
CertainPerformance
  • 356,069
  • 52
  • 309
  • 320