tags:

views:

12

answers:

1

I have the following block of code in a jQTouch app I'm working on:

<div class="info">
   <div id="MyValue">Sample Text</div>
</div>

<p onclick="ResetValue();">
   Reset
</p>

When writing my ResetValue method, the following jQuery syntax does not work:

$("MyValue").html("Changed Text");

However, if I use the "classic" method, the following text does work:

var value_block = document.getElementById("MyValue");
value_block.innerHTML = "Changed Text";

Is there something I'm missing with jQTouch or jQuery in general that is preventing the jQuery style code from working?

Note: I've also tried "wiring up" the click event to the paragraph (instead of using onclick directly in the tag) and get the same result.

+2  A: 

You're missing a # in the selector. It should be

$("#MyValue").html("Changed Text");

Some docs on selecting a div based on id in jQuery

Here's a demo of how I would do it.

irishbuzz
It's always something small like that. Works like a charm. Thanks!
Dillie-O