I have a heading on my webpage that I want to limit to a certain number of characters. The heading is for a blog post so the title changes. This is essentialy what I want to accomplish.
<body>
<script>
var x= document.getElementById("entry-title");
document.write(x.substring(0,10));
<script>
<h1 id="entry-title">This is a sample blog title</h1>
</body>
x.innerText = x.substring(0,10);do what you want?innerTextwill fail in Firefox. Either use jQuery or another library that covers up these differences, or feature-detect for the usage oftextContentinstead ofinnerText.