[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2011-10-15
7
Medium Priority
?
213 Views
Last Modified: 2012-06-27

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

0
Comment
Question by:AivsCoder
7 Comments
 
LVL 16

Expert Comment

by:HagayMandel
ID: 36974976
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
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 36975210
Possibly because it's wrong.  Should be "font-weight".
.boldness{
	font-weight: bold;
}

Open in new window

0
 
LVL 38

Expert Comment

by:Tom Beck
ID: 36975766
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 36976223
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
 
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 36976228
Here's the example with the PHP code left in:

addClass jquery (including original PHP)
0
 
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 36976231
(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
 

Author Closing Comment

by:AivsCoder
ID: 36977471
Awesome!!!.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question