Jquery - Get element by id constructing the id in string
<p>I have a trouble using an element with jquery. I am constructing the name in a var such as:</p>

<pre><code>var myId = "#" + myGotId;

$(myId).attr("title", "changed");
</code></pre>

<p>$(myId) is returning empty. I would want to get my element by id but constructing my Id dynamically joining strings.</p>

<p><em>edit by @Pointy</em> &mdash; additional code supplied in a comment by the OP:</p>

<pre><code>var form = $('form#formDefaultValue');
$(':submit', form).click(function(event) {
  event.preventDefault();
  $.post(form.attr('action'), form.serialize(), function(data, status, XMLHttpRequest) {
    if (status == 'success') {
      $("#msgInformation").html("Your changes have been successfully saved.");
      jQuery("#spanDefaultValue").attr("class", "db");
      var g = indexNodeSelected;
      g = g.replace("\\", "\\\\\\\\");
      $('#'+ g).find("span").attr("class", "");
   } 
</code></pre>
