Event Not Counting Number of Characters in TagHow do you disable browser Autocomplete on web form field / input tag?Getting the ID of the element that fired an eventWhy don't self-closing script elements work?jQuery get specific option tag textEvent binding on dynamically created elements?Best way to remove an event handler in jQuery?Where should I put <script> tags in HTML markup?RegEx match open tags except XHTML self-contained tagsIs it possible to apply CSS to half of a character?Cannot display HTML string
Rampant sharing of authorship among colleagues in the name of "collaboration". Is not taking part in it a death knell for a future in academia?
UX writing: When to use "we"?
Word for giving preference to the oldest child
Should students have access to past exams or an exam bank?
How does the barbarian bonus damage interact with two weapon fighting?
Derivative is just speed of change?
Avoiding Implicit Conversion in Constructor. Explicit keyword doesn't help here
"Fewer errors means better products" or fewer errors mean better products."
Move arrows along a contour
How does Asimov's second law deal with contradictory orders from different people?
How to remove rebar passing through an inaccessible pipe
What parameters are to be considered when choosing a MOSFET?
Why does Latex make a small adjustment when I change section color
Just how much information should you share with a former client?
Would people understand me speaking German all over Europe?
How to litter train a cat if both my husband and I work away from home all day?
Why didn't General Martok receive discommendation in Star Trek: Deep Space Nine?
What is the oxidation state of Mn in HMn(CO)5?
Stationing Callouts using VBScript Labeling in ArcMap?
Can I shorten this filter, that finds disk sizes over 100G?
How do discovery writers hibernate?
Scam? Checks via Email
Why don't short runways use ramps for takeoff?
NULL value causes blank row in SELECT results for text concatenation
Event Not Counting Number of Characters in Tag
How do you disable browser Autocomplete on web form field / input tag?Getting the ID of the element that fired an eventWhy don't self-closing script elements work?jQuery get specific option tag textEvent binding on dynamically created elements?Best way to remove an event handler in jQuery?Where should I put <script> tags in HTML markup?RegEx match open tags except XHTML self-contained tagsIs it possible to apply CSS to half of a character?Cannot display HTML string
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm having issues where my JavaScript code is not counting the characters that is being input and I'm at a lost. Any ideas?
HTML:
<script src="https://ajaxgoogleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<label for="studentName">Student name:</label>
<textarea id="studentName" cols="40" rows"3"></textarea><br>
<p id="stringLength">0</p>
JavaScript:
var $textareaElement = $("#studentName");
function textSize(event)
$("#stringLength").text($textareaElement.val().length);
/* Your solution goes here */
$(document).ready(function ()
$("#studentName").focus(function ()
$("#stringLength").html($(this).val().length);
);
);
Test:
Testing the number of characters in "Hi" is shown
Yours and expected differ. See highlights below.
Yours
0
Expected
2
Testing the number of characters in "How are you?" is shown
Yours and expected differ. See highlights below.
Yours
0
Expected
12
Testing the number of characters in "Good Game" is shown
Yours and expected differ. See highlights below.
Yours
0
Expected
9
jquery html dom-events
add a comment |
I'm having issues where my JavaScript code is not counting the characters that is being input and I'm at a lost. Any ideas?
HTML:
<script src="https://ajaxgoogleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<label for="studentName">Student name:</label>
<textarea id="studentName" cols="40" rows"3"></textarea><br>
<p id="stringLength">0</p>
JavaScript:
var $textareaElement = $("#studentName");
function textSize(event)
$("#stringLength").text($textareaElement.val().length);
/* Your solution goes here */
$(document).ready(function ()
$("#studentName").focus(function ()
$("#stringLength").html($(this).val().length);
);
);
Test:
Testing the number of characters in "Hi" is shown
Yours and expected differ. See highlights below.
Yours
0
Expected
2
Testing the number of characters in "How are you?" is shown
Yours and expected differ. See highlights below.
Yours
0
Expected
12
Testing the number of characters in "Good Game" is shown
Yours and expected differ. See highlights below.
Yours
0
Expected
9
jquery html dom-events
Where exactly istextSize
being used in the logic?
– Taplar
Mar 26 at 22:31
@Taplar wouldn't it be called while utilizing the function for the script?
– Ryan
Mar 26 at 22:37
Where is it utilized? You create the method and it's never used.
– Taplar
Mar 26 at 22:38
add a comment |
I'm having issues where my JavaScript code is not counting the characters that is being input and I'm at a lost. Any ideas?
HTML:
<script src="https://ajaxgoogleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<label for="studentName">Student name:</label>
<textarea id="studentName" cols="40" rows"3"></textarea><br>
<p id="stringLength">0</p>
JavaScript:
var $textareaElement = $("#studentName");
function textSize(event)
$("#stringLength").text($textareaElement.val().length);
/* Your solution goes here */
$(document).ready(function ()
$("#studentName").focus(function ()
$("#stringLength").html($(this).val().length);
);
);
Test:
Testing the number of characters in "Hi" is shown
Yours and expected differ. See highlights below.
Yours
0
Expected
2
Testing the number of characters in "How are you?" is shown
Yours and expected differ. See highlights below.
Yours
0
Expected
12
Testing the number of characters in "Good Game" is shown
Yours and expected differ. See highlights below.
Yours
0
Expected
9
jquery html dom-events
I'm having issues where my JavaScript code is not counting the characters that is being input and I'm at a lost. Any ideas?
HTML:
<script src="https://ajaxgoogleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<label for="studentName">Student name:</label>
<textarea id="studentName" cols="40" rows"3"></textarea><br>
<p id="stringLength">0</p>
JavaScript:
var $textareaElement = $("#studentName");
function textSize(event)
$("#stringLength").text($textareaElement.val().length);
/* Your solution goes here */
$(document).ready(function ()
$("#studentName").focus(function ()
$("#stringLength").html($(this).val().length);
);
);
Test:
Testing the number of characters in "Hi" is shown
Yours and expected differ. See highlights below.
Yours
0
Expected
2
Testing the number of characters in "How are you?" is shown
Yours and expected differ. See highlights below.
Yours
0
Expected
12
Testing the number of characters in "Good Game" is shown
Yours and expected differ. See highlights below.
Yours
0
Expected
9
jquery html dom-events
jquery html dom-events
edited Mar 27 at 7:54
Brian Tompsett - 汤莱恩
4,45214 gold badges40 silver badges108 bronze badges
4,45214 gold badges40 silver badges108 bronze badges
asked Mar 26 at 22:23
RyanRyan
612 silver badges9 bronze badges
612 silver badges9 bronze badges
Where exactly istextSize
being used in the logic?
– Taplar
Mar 26 at 22:31
@Taplar wouldn't it be called while utilizing the function for the script?
– Ryan
Mar 26 at 22:37
Where is it utilized? You create the method and it's never used.
– Taplar
Mar 26 at 22:38
add a comment |
Where exactly istextSize
being used in the logic?
– Taplar
Mar 26 at 22:31
@Taplar wouldn't it be called while utilizing the function for the script?
– Ryan
Mar 26 at 22:37
Where is it utilized? You create the method and it's never used.
– Taplar
Mar 26 at 22:38
Where exactly is
textSize
being used in the logic?– Taplar
Mar 26 at 22:31
Where exactly is
textSize
being used in the logic?– Taplar
Mar 26 at 22:31
@Taplar wouldn't it be called while utilizing the function for the script?
– Ryan
Mar 26 at 22:37
@Taplar wouldn't it be called while utilizing the function for the script?
– Ryan
Mar 26 at 22:37
Where is it utilized? You create the method and it's never used.
– Taplar
Mar 26 at 22:38
Where is it utilized? You create the method and it's never used.
– Taplar
Mar 26 at 22:38
add a comment |
1 Answer
1
active
oldest
votes
focus will fire when the element gains focus. keyup is what you're looking for if you want to count characters as user types them into the input.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55367020%2fevent-not-counting-number-of-characters-in-tag%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
focus will fire when the element gains focus. keyup is what you're looking for if you want to count characters as user types them into the input.
add a comment |
focus will fire when the element gains focus. keyup is what you're looking for if you want to count characters as user types them into the input.
add a comment |
focus will fire when the element gains focus. keyup is what you're looking for if you want to count characters as user types them into the input.
focus will fire when the element gains focus. keyup is what you're looking for if you want to count characters as user types them into the input.
answered Mar 26 at 23:56
Tom PimientaTom Pimienta
1093 bronze badges
1093 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55367020%2fevent-not-counting-number-of-characters-in-tag%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Where exactly is
textSize
being used in the logic?– Taplar
Mar 26 at 22:31
@Taplar wouldn't it be called while utilizing the function for the script?
– Ryan
Mar 26 at 22:37
Where is it utilized? You create the method and it's never used.
– Taplar
Mar 26 at 22:38