Reputation: 57
I'm trying to find line-through words in a HTML page.
I know how to find the CSS property
$(el).css('text-decoration');
This returns
line-through solid rgb(64, 64, 64)
The problem is that the color may differ, and solid might be different too. So I need something like:
$(el).css('text-decoration').contains('line-through');
but that won't work
Upvotes: 0
Views: 399
Reputation: 3735
$(element).css("property")
return string
in javascript, so use any method of string to find the matching content.
One of the method is yourstring.indexOf('somestring')
, if found then returns the index of first matched character else returns -1.
$(el).css('text-decoration').indexOf('line-through')
Upvotes: 0
Reputation: 9393
Since .css()
returns a string must use javascript string methods.
There are pretty much
out there pick one. indexOf, match, regular expressions
$(el).css('text-decoration').indexOf('line-through') // returns -1 if not found
Upvotes: 1
Reputation: 67207
String.indexOf() will help you in this context.
Try,
$(el).css('text-decoration').indexOf('line-through')
Upvotes: 0