Ive got a script which brings in some information regarding cars from a DVLA hook up.
$json = json_decode($response, true);
This then Shows on the page like this
Model: <?php echo $json['model']; ?><BR>
However, what I want to do is check the cars Model, and if the Model matches AUDI RS4 AUDI RS6 LOTUS MAZDA RX8
Then the page needs to show div B if, the mode is not on the exclude list then it can show div A.
So what I was thinking was something similar to this I found http://jsfiddle.net/9gHhD/
<cite class="fn"><?php echo $json['model']; ?></cite>
Which for testing looks like:
<cite class="fn">AUDI RS4</cite>
and then the script
var searchText = 'AUDI RS4' , 'AUDI RS6';
$('cite.fn').filter(function () {
return $(this).text() === searchText;
}) $("#excluded").css({display: "block"});
But this does not work. I dont know how to tell it to look for an array of different words? Or if this is even the best way to go about this?
Can anyone assist please
You can check against multiple string as follows:
$('cite.fn').filter(function () {
return ["blabla", "bla2bla"].includes($(this).text());
}).css('color', 'red');
Where as before you were limited to checking against a single string:
var searchText = 'blabla';
$('cite.fn').filter(function () {
return $(this).text() === searchText;
}).css('color', 'red');
Specifically, includes()
allows you to test against multiple string values.