I'm slowly getting acquainted with javascript and jquery, and I set up an example for the .addClass function, which unfortunately doesn't work as I would like it to....I checked the jquery api section on it and pasted its example in my code to see, if/how it works. I then returned to my example, however it still doesn't seem to be working for whatever reason. Maybe you guys can help me out on this, would be much appreciated.
Here's my code:
<!DOCTYPE html>
<html>
<head>
<style>
*{
margin:0;
padding:0;
}
.external {
background:dodgerblue;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<a href="https://www.macrumors.com">macrumors</a>
<script>
$("a[href^=http://]").addClass("external");
</script>
</body>
</html>
Here's my code:
<!DOCTYPE html>
<html>
<head>
<style>
*{
margin:0;
padding:0;
}
.external {
background:dodgerblue;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<a href="https://www.macrumors.com">macrumors</a>
<script>
$("a[href^=http://]").addClass("external");
</script>
</body>
</html>