AivsCoder
asked on
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>
This is my external css file
.header {
font-style : italic;
}
.boldness{
font-style : bold;
}
This is my external js file.
$(document).ready(function()
{
$('footer').addClass('boldness');
});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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
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
(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.
cheers.
ASKER
Awesome!!!.
You need to creare a div with an id "footer", and then use:
Open in new window
Pay attention to the '#' symbol.More on JQuery selectors.