admin管理员组

文章数量:1023758

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';

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';
Share Improve this question asked Dec 15, 2009 at 21:35 BrettkBrettk 3,0532 gold badges18 silver badges3 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6
$("#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>");
$("#listingTabs li").eq(2).text('insert new text');

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.

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';

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';
Share Improve this question asked Dec 15, 2009 at 21:35 BrettkBrettk 3,0532 gold badges18 silver badges3 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6
$("#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>");
$("#listingTabs li").eq(2).text('insert new text');

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.

本文标签: