Reputation: 19571
Im trying to get the text in a td with an id of "warningLabel", add to the text, then put the new text in the td.
I tried:
$('#warningLabel').html($('#warningLabel').html()+ "Please enter a date.\n");
This doesnt work but it doesnt raise any errors in firebug either.
If it matters, "warningLabel" may have no text in it to begin with.
How should i be doing this?
Update
The td in question starts out hidden
More of my code:
$(function(){
function fieldsEntered(){
var check = true;
if($('#date').val()==""){
$('#warningLabel').html($('#warningLabel').html()+ "Please enter a date.\n");
check = false;
}
if($('#warningLabel').html()!=""){
$('#warningLabel').show();
}
return check;
}
});
Upvotes: 0
Views: 38
Reputation: 6907
Have you heard of .append()?
Just try,
$('#warningLabel').append("Please enter a date.<br>");
Here is a DEMO showing how it works.
Also try showing the td after you add content to your warningLabel.
Upvotes: 3