How do you get the length of a string?

2019-01-30 01:18发布

How do you get the length of a string in jQuery?

9条回答
Melony?
2楼-- · 2019-01-30 01:47

jQuery is a JavaScript library.

You don't need to use jQuery to get the length of a string because it is a basic JavaScript string object property.

somestring.length;
查看更多
萌系小妹纸
3楼-- · 2019-01-30 01:51

You don't need to use jquery.

var myString = 'abc';
var n = myString.length;

n will be 3.

查看更多
贪生不怕死
4楼-- · 2019-01-30 01:52

HTML

<div class="selector">Text mates</div>

SCRIPT

alert(jQuery('.selector').text().length);

RESULT

10

查看更多
登录 后发表回答