SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    REplacing Text With jQuery

    I am having trouble with what I thought would be easy. I need to replace (remove) text from a list of text. In the following code (that is dynamically created) I need to remove "School of "

    <div class="siteMap">
    <ul>
    <li id="school-of-liberal-arts">
    <a href="/academics/undergraduate/schools/school-of-liberal-arts/">School of Liberal Arts</a>
    </li>
    <li id="school-of-natural-and-applied-sciences">
    <a href="/academics/undergraduate/schools/school-of-natural-and-applied-sciences/">School of Natural &amp; Applied Sciences</a>
    </li>
    <li id="school-of-business">
    <a href="/academics/undergraduate/schools/school-of-business/">School of Business</a>
    </li>
    <li id="school-of-professional-studies">
    <a href="/academics/undergraduate/schools/school-of-professional-studies/">School of Professional Studies</a>
    </li>
    </ul>
    </div>


    I am using jQuery for this website.

    Any thoughts or insights would be most appreciated!

  2. #2
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    336
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Code JavaScript:
    $(document).ready(function() {
    	$('.siteMap ul li a').each(function() {
    		var txt = $(this).text();
    		txt = txt.split('School of ')[1];	
    		$(this).text(txt);
    	});
    });


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •