[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 474
  • Last Modified:

jquery - get text after certain character?

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?
0
n00b0101
Asked:
n00b0101
1 Solution
 
Greg AlexanderLead DeveloperCommented:
Looking for something like this?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
	 var variable = $("#cti").val().split("|")[1];
	 alert(variable);
});
</script>
<input type="text" value="Contact|timber" name="ct" id="cti" />

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now