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.
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;