Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

truncate string?

Posted on 2011-09-07
2
Medium Priority
?
280 Views
Last Modified: 2012-05-12
  $('div[id*="landmark"]').each(function ()
            {
                $(this).text($(this).attr("id")).css("width", "100px").css("height", "100px").css("border", "1px solid red");
            });

Open in new window



Now, is there a way to cut out the "landmark" part and just display the characters after?

instead of:

landmarkA
landmarkZ
landmarkWhatever
landmarkFoo
landmarkBar

the inner text for the div would just be:

A
Z
Whatever
Foo
Bar
0
Comment
Question by:Tom Knowlton
2 Comments
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 36496201
yes :$(this).text($(this).attr("id").split("landmark")[0]).css("width", "100px").css("height", "100px").css("border", "1px solid red");
or :$(this).text($(this).attr("id").replace("landmark","")).css("width", "100px").css("height", "100px").css("border", "1px solid red");
0
 
LVL 5

Author Closing Comment

by:Tom Knowlton
ID: 36496392
thx
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

885 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