我试图从CSS截断元素中获取HTML并且似乎无法正确使用它.
例如:
<span id=mySpan style=white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:50px>This is the contents of the span tag. It should truncate with an ellipsis if it is longer than 50px.</span>
Run Code Online (Sandbox Code Playgroud)
如果我使用标准的jQuery方式来获取HTML,我会得到全文,而不是截断的版本.我不确定它是否可能.
html = jQuery('#mySpan').html();
text = jQuery('#mySpan').text();
Run Code Online (Sandbox Code Playgroud)
两者都返回全文.我很难过.