Why isn't this css class being added to my footer tag via JQuery.


Here is my HTML5 and PHP
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8"/>
<link rel="stylesheet" href="css/mycss.css"/>
<script src="jquery-1.6.2.min.js"></script>
<script src="myjs.js"></script>
<body>
<?php
	$firstname = "Ben";
	$secondname = "Benn";
	$actualname = "";
	
	const MYNICKNAME = "benny";
	define("MYCONSTANT","Benny Bong");
	if ($firstname === $secondname) { echo "They are the same"; } else { echo "They are different"; }
	 
	echo MYNICKNAME;
	echo MYCONSTANT;
	
	$actualname = (isset($firstname)) ? $firstname : $secondname;
	echo $actualname;
?>
<header class="header">
Ben
<nav></nav>
</header>
	
<aside>
Ben
</aside>
<footer>
Ben
</footer>

</body>
</html>

Open in new window


This is my external css file
 
.header {
	font-style : italic;
}

.boldness{
	font-style : bold;
}

Open in new window


This is my external js file.
$(document).ready(function() 
{
	$('footer').addClass('boldness');
});

Open in new window

AivsCoderAsked:
Who is Participating?
 
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
Possibly because it's wrong.  Should be "font-weight".
.boldness{
	font-weight: bold;
}

Open in new window

0
 
HagayMandelCommented:
The JQuery function will be applied to a div with a specific id or class.
You need to creare a div with an id "footer", and then use:
$(document).ready(function() 
{
	$('#footer').addClass('boldness');
});

Open in new window

Pay attention to the '#' symbol.
More on JQuery selectors.
0
 
Tom BeckCommented:
I don't have a solution to provide, I'm just weak on jQuery and trying to learn, so I'd like to ask @HagayMandel a question. Does jQuery recognize HTML5 tags at all? Because the author's jQuery should work if it did.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Kyle HamiltonData ScientistCommented:
jquery recognizes html5 tags. But IE < 9  doesn't.  

I commented out your php - there is an error preventing the page from displaying in IE.

Here is a working file for all browsers but IE < 9:
addClass jquery
0
 
Kyle HamiltonData ScientistCommented:
Here's the example with the PHP code left in:

addClass jquery (including original PHP)
0
 
Kyle HamiltonData ScientistCommented:
(could just be the php configuration on my server - but I don't think you're supposed to use const as a global variable)

cheers.
0
 
AivsCoderAuthor Commented:
Awesome!!!.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.