You are here: Re: Changing Data Values using CSS « HTML « IT news, forums, messages
Re: Changing Data Values using CSS

Posted by Toby A Inkster on 07/18/07 09:36

sgconger wrote:

> I have a list of data values that are in an html <span id=x>1. My List
> One</span>. I want to be able in CSS (not change the html) to remove
> the 1. so that when it is displayed all I get is My List One. It
> seems like there should be a way to do this using CSS.

You could remove the "1", but you can't easily remove the ". ". To remove
the "1" you can use:

#x:first-letter { display: none; }

but this will only work when used on a block element (e.g. <div>, <p>,
etc) -- not on an inline element (e.g. <span>).

You'd be better off using client-side scripting. Something like:

<script type="text/javascript">
function addEvent(obj, evType, fn)
{
if (obj.addEventListener)
{
obj.addEventListener(evType, fn, false);
return true;
}
else if (obj.attachEvent)
return obj.attachEvent('on'+evType, fn);
else
return false;
}

function my_changer()
{
var span = document.getElementById('x');
var x = span.innerHTML.replace(/^[0-9]+\.\s*/, '');
span.innerHTML = x;
}
addEvent(window, 'load', my_changer);
</script>

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 27 days, 12:59.]

PHP Linkifier
http://tobyinkster.co.uk/blog/2007/07/18/linkify/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация