Solved

truncate string?

Posted on 2011-09-07
2
270 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:knowlton
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
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:knowlton
Comment Utility
thx
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

772 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

10 Experts available now in Live!

Get 1:1 Help Now