Reputation: 3053
Using JQuery, I can do the following to get the text within my LI
$("#listingTabs li").eq(2).text();
How do I set the text? Because the following doesn't work
$("#listingTabs li").eq(2).text() = 'insert new text';
Upvotes: 1
Views: 517
Reputation: 94147
The text()
function works as both a getter and a setter. Try this:
$("#listingTabs li").eq(2).text('insert new text');
If you give it a parameter, it acts as a setter for that property. If you don't, it acts as a getter.
Upvotes: 4
Reputation: 3431
$("#listingTabs li").eq(2).text("insert new text");
You can also set the innerHTML of the li using
$("#listingTabs li").eq(2).html("<b>insert new text</b>");
Upvotes: 6