.html(), .before() and .after() not working were .text() does...

.html(), .before() and .after() not working were .text() does...

The .html(), .before() and .after() methods aren't working for me but strangly if I replace .html() with .text() and leave everything else the same then that part works.

What's also strange is that sometimes it .html() etc work and other times they don't...

I have the following code in a linked js file:

  1. function getMatch (id, template)
    {
    db.transaction(
    function (transaction) {
    transaction.executeSql(
    "SELECT * FROM matches WHERE (id = ?) LIMIT 1",
    [id],
    function (transaction, result) {
    var row = result.rows.item(0)
    template.html(row.title);
    },
    errorHandler
    );
    }
    );
    }

...and this in my html file:

  1. <html>
    <head>
      <script type='text/javascript' charset='utf-8' src='js/jquery.1.3.2.min.js'></script>
      <script type="text/javascript" charset="utf-8" src="js/db.js"></script>
      <script charset="utf-8" type="text/javascript">
        $(document).ready(function() {
          getMatch('1', $("#template"));    
        });
      </script>
    </head>
    <body>
      <div id="template"></div>
    </body>
    </html>

Does any one have an idea why these methods aren't working for me?

Many thanks, Matthew