Reputation: 13843
I have the following jQuery:
j(".refreshMe").html(html);
var something = $("li", html).length;
if ( something > 0 ) {
j('.showlatest').slideDown();
}
and HTML:
<p class="showlatest"></p>
What I want to happen is,
if ( something > 0 ) {
j('.showlatest').slideDown();
ADD THE CONTENTS OF 'something' WITH THE TEXT 'NEW MESSAGES'
}
E.g.
<p class="showlatest">2 new messages</p>
I suppose I could define the 'New Messages' text as:
var newmessages = "New Messages";
But how can I then, in PHP speak, echo the results?
Upvotes: 0
Views: 16466
Reputation: 887365
You can call the .text()
method to set the text of an element, like this:
j('.showlatest').text(something + ' New Messages');
Upvotes: 6