Solved

truncate string?

Posted on 2011-09-07
2
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 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

Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

Question has a verified solution.

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

DOM Attributes and Properties treatment with jQuery 1.6 by Ivo Stoykov jQuery (http://jquery.com/) 1.6 introduces .prop() (http://api.jquery.com/prop/) and .removeProp() (http://api.jquery.com/removeProp/) methods which allow modifying or removi…
Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
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)

710 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