How do you get the length of a string in jQuery?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to fix IE ClearType + jQuery opacity problem i
- void before promise syntax
- jQuery add and remove delay
You don't need jquery, just use
yourstring.length
. See reference here and also here.In jQuery :
OR
In JS :
same way you do it in javascript:
"something".length
The easiest way:
It's not jquery you need, it's JS:
A somewhat important distinction is if the element is an input or not. If an input you can use:
otherwise if the element is a different html element like a paragraph or list item div etc, you must use