Target escaped div string

Target escaped div string

Trying to target a div that may have some special characters in it & then change it's srcset.
Everything is coming in correctly, so it's just the targeting part that I need help with.

I broke it down into parts to be able to concatenate & then target it:

  1. var smdiv = 'mydiv_rowset_'+rowset+'_'+mydata[rowset].fieldNames[k];
  2. var smesc = smdiv.replace(/[!"#$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g, "\\\\$&");
  3. var smimgsrc = ' source\\\\.img2xsm';
  4. var small = '\\\\#'+smesc+smimgsrc;
  5. console.log('SmImg-small: ' + small); // Ex. \\#mydiv_rowset_mytable31_field8\\@2x source\\.img2xsm
  6. $(small).attr('srcset', 'some new value');  // Throws syntax error, unrecognized expression on what's placed in for 'small'

Basic html:

  1. <span id="mydiv_rowset_mytable31_field8@2x" class="myclass">
  2.   <picture>
  3.     <source class="img2xsm" srcset="~~">
  4.   </picture>
  5. </span>

I've tried $('small') and $('"'+small+'"')...  still doesn't work.  What am I missing as the target is now an escaped string?