Internal style and script in head are not applied [closed] - javascript

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am using Joomla and the T3 template. I added the following "Custom Code" before the </head> tag:
<style type="text/stylesheet">
div.t3-sidebar.t3-sidebar-right{
background: #F8F8F8 none repeat scroll 0% 0%;
border: 1px solid rgb(238, 238, 238);
border-radius: 20px;
}
button.btn.btn-primary.off-canvas-toggle{
font-size: 28px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("button.btn.btn-primary.off-canvas-toggle i.fa.fa-bars").addClass("fa-user").removeClass("fa-bars");
});
</script>
When I use my browsers development tools I can see those tags in the head where they should be, but when I inspect the elements, the styles are not applied.
Edit: the style is working now, I foolishly used the wrong type. Thank you to everyone who proposed this change.
Concerning the script problem: I do not get any errors in the console.
Final Edit: The problem with the script is resolved. It was either a problem with the name of the jQuery function (jQuery instead of $) or a problem with the brackets of the document.ready function.

Your CSS is not working, because
<style type="text/stylesheet">
should be
<style type="text/css">
And your javascript is not working, because you did not import jQuery.
There are many ways to import jQuery, this is one of them:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

It should be text/css
Here is the modified code.
<style type="text/css">
div.t3-sidebar.t3-sidebar-right{
background: #F8F8F8 none repeat scroll 0% 0%;
border: 1px solid rgb(238, 238, 238);
border-radius: 20px;
}
button.btn.btn-primary.off-canvas-toggle{
font-size: 28px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("button.btn.btn-primary.off-canvas-toggle i.fa.fa-bars").addClass("fa-user").removeClass("fa-bars");
});
</script>

Related

Can't add css class to element [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I am trying to add class to element.
.html5-video-player {
-webkit-transform: rotate(90deg) !important;
-moz-transform: rotate(90deg) !important;
-o-transform: rotate(90deg) !important;
-ms-transform: rotate(90deg) !important;
transform: rotate(90deg) !important;
}
test
I can't add CSS to element. I need to rotate in mobile devices. So I will later add bootstrap class #media (max-width: 767.98px) { to element after make it working.
Here is codepen.
I can't directly embed video in my website as I don't have space for that. I need it as link or link button. If watch_popup method don't work, I can also try bootstrap modal which has button, clicking on it will pop up embeded video. Rotating that to 90 degree to full screen also acceptable. Or any other javascript/jQuery method out there to make it happen? I need the rotation(Full screen) in mobile devices only.
I added the video content in <iframe>. Clicking <button> rotates <iframe> 90 degrees.
function rotate(){
document.getElementById("special-container").setAttribute("style", "display: inline !important");
document.getElementById("camera_view").setAttribute("style","transform: rotate(90deg)");
}
a{
background-color: #4CAF50;
border: none;
color: white;
padding: 5px 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<a onclick="rotate()">Rotate</a>
<div id="special-container" class="embed-responsive embed-responsive-16by9" style="display: none;">
<iframe id="camera_view" class="embed-responsive-item container well well-small span6"
style="height: 720px; width: 1280px; background-color: #2e2e2e;"
src="https://www.youtube.com/watch_popup?v=p-_qed5LTTg">
</iframe>
</div>
</body>
</html>
You forgot class="html5-video-player" in thé link 'a'

Fixed element at end of div [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am searching a lot but don't know how to name it properly.
Idea:
We have two divs together. The first one on the left have a lot of content, more than the one on right side. The second one have only form to be filled up and send. When user scrolls the left div for more information, the right side with contact form will follow to the end of this div. And when user scrolls up, this form on the right will follow it too.
How to detect it? Is there any framework?
I have a lot of divs in website and each one must have this script.
Screen to show what I mean:
Link to page:
LINK
Check following links:
http://www.jqueryscript.net/layout/jQuery-Plugin-To-Fix-Element-Within-Its-Parent-Container-nail.html
Demo: http://www.jqueryscript.net/demo/jQuery-Plugin-To-Fix-Element-Within-Its-Parent-Container-nail/
http://www.jqueryscript.net/layout/Super-Tiny-jQuery-Plugin-For-Sticky-Elements-Sticky.html
Demo: http://www.jqueryscript.net/demo/Super-Tiny-jQuery-Plugin-For-Sticky-Elements-Sticky/
http://www.jqueryscript.net/layout/Multipurpose-jQuery-Sticky-Sidebar-Plugin-scrollWith.html
Demo: http://www.jqueryscript.net/demo/Multipurpose-jQuery-Sticky-Sidebar-Plugin-scrollWith/scrollwith-single-first.html
You can use the CSS position: fixed; for the right side.
is this what you want. the concept is to use position:fixed and right:0 and/or top:10px properties with your css. this is a small example for it.hope this will help.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<style type="text/css">
body{
width: 100%;
height: 1000px;
background-color: orange;
}
.right{
width: 30%;
position: fixed;
right: 0;
height: 500px;
background-color: gray;
}
.check{
position: absolute;
top: 900px;
}
</style>
<body>
<div class="right">
<h2>send an email</h2>
</div>
<h1 class="check">checkin the view</h1>
</body>
</html>
values are to get an idea, change those as your need.

jquery fadeIn function with as callback function with $("this") parameter [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I'm trying to do a simple function so an element will fade in and then will fade out.
This is my code:
function ShowBoxes() {
$("#divTestArea21").fadeIn("fast", function () {
FadeThisOut($(this));
});
$("#divTestArea22").fadeIn("slow");
$("#divTestArea23").fadeIn(2000);
}
function FadeThisOut(sender) {
sender.fadeOut("slow");
}
<!DOCTYPE html>
<html>
<head>
<title>jQuery test</title>
<script src="Scripts/jquery-2.2.0.js"></script>
<script type="text/javascript" src="Scripts/IndexScript.js"></script>
<link href="CSS/SiteStyle.css" rel="stylesheet" />
<meta charset="utf-8" />
</head>
<body>
<div id="divTestArea21" style="width: 50px; height: 50px; display: none; background-color: #89BC38;"></div>
<div id="divTestArea22" style="width: 50px; height: 50px; display: none; background-color: #C3D1DF;"></div>
<div id="divTestArea23" style="width: 50px; height: 50px; display: none; background-color: #9966FF;"></div>
Show boxes
</body>
</html>
Can someone please explain to me why it isn't working and how to fix it?
Edit: you are right, I had a paramater for FadeThisOut function , but I played with my code for a bit and tried other things so I forgat to bring it back. Anyway, I removed the double-quotes and now it's working. Thanks all.
First you call your function with $(this) as parameter but you declare it without, start by putting it this way :
function FadeThisOut(object) {
}
Secondly you use sender[0], but you don't show us what is sender array.
Thirdly in your function call, you should call the current object without quotes, ie: $(this)
Did you mean to use
FadeThisOut($(this));
(without the double-quotes)
As Vincent said, you also have no argument to the FadeThisOut function

jQuery doesn't seem to work when previewing [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I'm very new to coding so I need help from you guys!
I wrote these codes to run a test but I can't seem to get the jQuery to load when previewing in Chrome. (I use Atom to code)
HTML
<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
<link type="text/css" rel = "stylesheet" href = "stylesheet.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<h1>Hello</h1>
<p>This is just a test</p>
<div></div>
</body>
</html>
CSS
h1 {
color: #6D9CAE;
font-family: Futura;
font-size: 40px;
font-weight: lighter;
}
h2 {
color: #bb2025;
font-family: Futura;
font-size: 40px;
font-weight: lighter;
}
p {
color: #54748B;
font-family: Avenir;
font-size: 20px;
font-weight: bold;
}
div {
background-color: #223C4A;
height: 100px;
width: 100px;
border-radius: 100%;
}
.active {
background-color: #a5b000;
}
javascript
$(document).ready(function(){
$('div').hover(function(){
$('div').addClass('.active')
});
});
I'm trying to get the div to change a color when hover over but it just can't work. Not sure if I did anything wrong with the javascript.
I tried to copy a working code (html, css, script) from somewhere and preview it using chrome and safari and that won't work either.
So, how do I get the script to work when previewing??
Thanks!!
You need to remove the '.' from '.active' when you use '.addClass'
try this:
$(document).ready(function(){
$('div').hover(function(){
$('div').addClass('active');
});
});

CSS/Javascript Error [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
If fixed all of the issues I had yesterday, but when I drag my file into any brower, it just says "Hello" and doesn't include the element at all nor does it hide when clicked.
MyIndex.html
<!DOCTYPE HTML>
<HTML>
<head></head>
<body>
<title>Mary Bishop</title>
<link href="stylesheet.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js'></script>
<script type="text/javascript" src="jscript.js"></script>
<div ID="contact">Hello</div>
</body>
</HTML>
stylesheet.css
#contact {
height: 100px;
width: 100px;
background-color: #517F8F;
border-radius: 25px;
border: 2px solid blue;
text-align: center;
display: block;
text-align: center;
vertical-align: middle;
line-height: 100px;
}
jscript.js
$(document).ready(function(){
$('#contact').click(function(){
$(this).hide();
});
});
I moved the body tag up to include all of the links (as you can see in the current HTML file), but that didn't change anything :( I'm so confused. Any help would be greatly appreciated. Thanks
You probably have your files inside of other folders. For example, does the folder that contains your files look something like this?:
MyWebsite
scripts <-- this is a folder
jscript.js <-- this file is in the "scripts" folder
stylesheets
stylesheet.css
MyIndex.html
If so, then you'll need to update your <link> and <script> tags so that they look like this:
<link href="stylesheets/stylesheet.css" type="text/css" rel="stylesheet">
^^^^^^^^^^^^ <- this should be the name of the folder
that your stylesheet lives in
<script type="text/javascript" src="scripts/jscript.js"></script>
^^^^^^^^
Basically, you need to add the appropriate folders to your links: otherwise they point to the wrong place.
You can quickly load the source code for your webpage by hitting [control][u] in Chrome. You will then see the JavaScript and Stylesheet URLs as links. You can click on these to follow them to see if they are working correctly.
The <body> element should include only the <div> element. Otherwise, the code you posted seems to be working. Check to make sure this fiddle is what you want.
Html:
<div ID="contact">Hello</div>
CSS:
#contact {
height: 100px;
width: 100px;
background-color: #517F8F;
border-radius: 25px;
border: 2px solid blue;
text-align: center;
display: block;
text-align: center;
vertical-align: middle;
line-height: 100px;
}
JavaScript:
$(document).ready(function(){
$('#contact').click(function(){
$(this).hide();
});
});

Categories