Need to use `json_encode` here, which means you can also skip the quotes:

```diff
- $('<?php echo esc_attr( $selector ); ?>')
+ $( <?php echo json_encode( $selector ); ?> ) 
```