I've got the following field on an MVC view:
@Html.TextBoxFor(model => model.Course.Title, new { data_helptext = "Old Text" })</span>
In a seperate js file, I want to set the data-helptext attribute to a string value. Here's my code:
alert($(targetField).data("helptext"));
$(targetField).data("helptext", "Testing 123");
The alert() call works fine, it shows the text "Old Text" in an alert dialog. However, the call to set the data-helptext attribute to "Testing 123" does not work. "Old Text" is still the attribute's current value.
Am I using the call to data() incorrectly? I've looked this up on the web, and I can't see what I'm doing wrong.
Here's the HTML markup:
<input data-helptext="Old Text" id="Course_Title" name="Course.Title" type="text" value="" />