I'm trying to compare text in an unordered list to an array that I created by grabbing contents in a string then parsing it. I cannot seem to get the comparison part of my jQuery code to work where I check to see if the string lives within the array. Any suggestions?
HTML
<span id="Subjects">Commercial Law & Contracts, Immigration Law, International Law & Trade, Products Liability</span>
<ul id="SubjectList">
<li>Administrative Law</li>
<li>Agriculture Updates</li>
<li>Alternative Dispute Resolution</li>
<li>Antitrust & Trade Regulation</li>
<li>Commercial Law & Contracts</li>
<li>Immigration Law</li>
<li>International Law & Trade</li>
<li>Products Liability</li>
</ul>
JQuery Code
var subject_passed = $('#Subjects').text();
var subjectArray = new Array();
subjectArray = subject_passed.split(',');
$('#SubjectList li').each(function(){
if ($.inArray($(this).text(), subjectArray) != -1) {
alert('hello');
}
});
var subjectArray=$('#Subjects').text().split(', ');