title: Jquery data-target as string possible?
body: <p>I have a data-attribute with a unique name and a number at the end. </p>
  
  <pre><code>data-target="foo-bar-n"
  </code></pre>
  
  <p>where n is the unique number.</p>
  
  <p>I want to be able to get that number but it isn't working.</p>
  
  <p>I call:</p>
  
  <pre><code>.data("target")
  </code></pre>
  
  <p>on the object I want the target from and It returns fine, but when I use a regex search on the results, I get a completely different number, which I suspect is because returned data is an object with other data. What I need to know is how to get that number out, or how to convert the data-attribute into a string. (I've tried toString, and that doesn't work.)</p>
  
  <p>Here is my code:</p>
  
  <pre><code>var selection= window.getSelection().getRangeAt(0);
  var showSelection = $(selection.commonAncestorContainer.parentNode.parentNode)
    .data('target');
  console.log(showSelection);
  console.log(showSelection.search(/\d+/));
  </code></pre>
  
  <p>The console logs</p>
  
  <pre><code>#comment_for_paragraph_17
  23
  </code></pre>
  
  <p>The program is meant to let a user select something on the page and highlight it.</p>