0

how to select first characterin html DOM. I tried $('#pcode')[0]; to get first character but its not giving first value when I am trying to print it its printing [object HTMLInputElement] how to select HTML DOM first character using jquery

1
  • 3
    Please post your HTML and JavaScript. Commented Nov 8, 2013 at 20:04

2 Answers 2

1

If I understand you correctly, you have some text in an element with the id "pcode" and you want the first character. If that is so then you want to do the following:

$("#pcode").val().charAt(0);
Sign up to request clarification or add additional context in comments.

1 Comment

@Krishna..yeah thnq :)
0

You're just pulling the object with

$('#pcode')[0];

You need to pull the value associated with the object

$('#pcode').val()[0];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.