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
3 Answers
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
3 Answers
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.
本文标签:
版权声明:本文标题:javascript - JQuery: .text() get the html within a node, how do I set the text within a node? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745561520a2156188.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论