I am currently working on some code that changes html presentation by changing classes identified in my CSS document. I as hoping to use a Core.hasClass() function to ensure that things follow through properly and take additional steps if they are not.

HTML Code:
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en-US">
<meta http-equiv="content-type" content="text/css" charset="utf-8" />
<title>Pizza Party!</title>
<div class="header">
<p class="tagline">Welcome to the greatest Pizza Parlor in Mt. Kisco!</p>
<div id="list_1" class="ingredients">
<p>While our Pizzas are exquisite without toppings, our customers often enjoyo a mixture of vegetarian and meat additions.</p>
<h3>Vegetarian option</h3>
		<li>Bell Peppers</li>
		<li>Banana Peppers</li>
		<li>Buffalo Chicken</li>
		<li>Grilled Chicken</li>
		<li>BBQ Chicken</li>
<div id="footer"">
<p class="additional">hi</p>
<script type="text/javascript">
Core.hasClass = function(target, theClass) {
var pattern = new RegExp("(^| )" + theClass + "( |$)");
if (pattern.text(target.className) {
return true;
return false;
var div2=document.getElementById("list_1");
if (Core.hasClass(div2, "ingredients")) {
alert("The second div element has the matching class");
HTML Code:

The Core.hasClass I took from Kevin Yank's Simply Javascript book. I'm not entirely sure why this code is not working, but my intention is to throw the Core.hasClass into an external file and reference it similar to the conditional code.