'How prevent DOM XSS

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.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source