Following is the Jsfiddle I tried
<span>*</span>
<br>
<span>*</span>
<br>
<span>hdhdf</span>
span[text='*']
{
color:red;
}
what i want is the two spans with * content in it to be accessed from css?
Following is the Jsfiddle I tried
<span>*</span>
<br>
<span>*</span>
<br>
<span>hdhdf</span>
span[text='*']
{
color:red;
}
what i want is the two spans with * content in it to be accessed from css?
Not sure if this is possible without using data attributes instead: http://jsfiddle.net/TkKwp/
HTML:
<span data-text="*"></span>
CSS:
span[data-text="*"]:before {
content: attr(data-text);
color: red;
width: 15px;
height: 15px;
}
Without the extra class, this might be helpful:
EDITED
HTML
<span>*</span>
<br>
<span>*</span>
<br>
<span>hdhdf</span>
CSS
span:nth-child(1),
span:nth-child(2){
color:red;
}
EDITED.
just Using CSS results cannot be achieved unless you use some attribute in span
tag.
However using a bit jquery .filter() you can get the result.
check the DEMO.
$('span')
.filter(function(){ return $(this).text() == '*'; })
.css('color','#ef8913');
You cannot get from the text value directly, you can use JQuery or Javascript to do such a job based on the internal contents but still you need to be operating in the definitions of CSS.