title: jquery change text of anchor link
body: <p>I have this anchor link:</p>
  
  <pre><code>&lt;li&gt;&lt;a class="tab" id="watchTicket" href="#" onclick="CallPage('/section/tickets/view-ticket?action=watch&amp;seq=&lt;?php echo $_GET["seq"]; ?&gt;');"&gt;&lt;?php echo ($TicketWatched ? 'Un-Watch' : 'Watch'); ?&gt;&lt;/a&gt;&lt;/li&gt;
  </code></pre>
  
  <p>i want to be able to change the text inside it using jquery, i have tried:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $("a#watchTicket").text('Watch');
  &lt;/script&gt;
  </code></pre>
  
  <p>and </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $("li a#watchTicket").text('Watch');
  &lt;/script&gt;
  </code></pre>
  
  <p>but neither are changing the text, and no errors are in the console</p>
  
  <p>i have this jquery function:</p>
  
  <pre><code>function CallPage(url) {
      $.ajax({
          url: url,
          dataType: 'jsonp',
          success: function(data){
  
          }
      });
  }
  </code></pre>
  
  <p>that calls a page, this is the function used in the anchor <code>OnClick</code></p>
  
  <p>all of this code is on a single page, and i change the text at the top of the page - that is using PHP and JQuery:</p>
  
  <pre><code>&lt;?php
  if($_GET["action"] == 'watch' &amp;&amp; isset($_GET["seq"])) {
      // SQL Query here
      ?&gt;
      &lt;script type="text/javascript"&gt;
      $(document).ready(function(){
          $("a#watchTicket").text('Watch');
      });
      &lt;/script&gt;
      &lt;?php
  }
  ?&gt;
  </code></pre>
  
  <p>then the actual anchor link is below this code</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>i have just changed my function to:</p>
  
  <pre><code>function WatchTicket() {
      $.ajax({
          url: 'view-ticket?seq=&lt;?php echo $_GET["seq"]; ?&gt;&amp;action=watch',
          dataType: 'jsonp',
          success: function(data){
              var text = $("a#watchTicket").text();
  
              if(text === "Watch") {
                  $("a#watchTicket").text('Un-Watch');
              } else {
                  $("a#watchTicket").text('Watch');
              }
          }
      });
  }
  </code></pre>
  
  <p>which i call in the <code>OnClick</code> of the anchor tag</p>
  
  <p>but now this isnt changing the text although the call is successful?</p>