jquery - get text after certain character?

Posted on 2011-04-25
Last Modified: 2012-05-11
Probably an easy question for someone that knows jquery... I've tried using split, but it's not giving me expected results...

I have an input like this:
<input type="text" value="Contact|timber" name="ct" id="cti" />

Open in new window

And, I'm trying to store |timber (the pipe and the characters immediately following it) in a variable.  Anyone know how to do that?
Question by:n00b0101
    1 Comment
    LVL 18

    Accepted Solution

    Looking for something like this?
    <script src=""></script>
    	 var variable = $("#cti").val().split("|")[1];
    <input type="text" value="Contact|timber" name="ct" id="cti" />

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: Create Mobile App Prototypes with Adobe XD

    This is a project-based course: we go through all the steps of creating a prototype from start to finish, using all the tools and features currently available in Adobe XD. You can complete the course in less than a day, plus all project files and fonts are included.

    I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
    JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    The viewer will learn how to dynamically set the form action using jQuery.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now