I am trying to replace the content of a <td> element when it exactly matches a string. My code does not seem to work, can anyone please say what I might be doing wrong?
<script>
$(document).ready(function(){
$("td").click(function(){
if (Matches(this, "1")
ReplaceCellContent(this,"A");
});
});
<!-- Replaces an HTML inner value [find] with a new value [replace] -->
function ReplaceCellContent(element, replace) {
$(.element).html(replace);
}
<!-- Returns true if [element] contains [stringToMatch] -->
function Matches(element, stringToMatch) {
return $(element).text() === stringToMatch;
}
</script>
Unexpected identifierwith line 5, which calls theReplaceCellContentfunction. Unfortunately I can't see what is wrong with it.