Function doesn't work with latest API
I have the following character counting code. It works fine if the line to load the API is
jquery/1.4/jquery.min.js. If I change it to
jquery/1.10.2/jquery.min.js, the div doesn't update. Would someone point out the problem, please?
- <div><input type="text" name="title" value="Replace me" id="pagetitle"
- onkeyup="javascript:return ShowCharacterCount('pagetitle')">
- </div>
- <div><input type="text" disabled name="title_cnt" id="pagetitle_cnt" value="0"></div>
- <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
- function ShowCharacterCount(id) {
- var cnt = ($("#" + id).attr("value")).length; //how many characters in box
- var dest = id + "_cnt";
- $( "#" + dest ).val( cnt ); //display the new count
- }