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 8 years ago.
Improve this question
How to paste JavaScript/jQuery code in blogger post?
Such like jsfiddle.net/tTman
It didn't work, don't know what I miss?
Please guide me the correct way to achieve my objective .
(Newbie learning)
My guess would be that you did not load the jquery library. Pasting the following code in the HTML view of a blog-post should work:
<img id="b" src="http://www.web-press.it/folder/servizi_cloud.jpg" id="b" style="position:absolute; top:50px"/>
<!-- Loading the required JQuery library -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
function moveRight(){
$("#b").animate({left: "+=300"}, 2000,moveLeft)
}
function moveLeft(){
$("#b").animate({left: "-=300"}, 2000,moveRight)
}
$(document).ready(function() {
moveRight();
});
</script>
follow this path:
blogger.com -> Template -> Edit HTML
and past your javascript/jquery codes before </head>
<script type="text/javascript">
function moveRight(){
$("#b").animate({left: "+=300"}, 2000,moveLeft)
}
function moveLeft(){
$("#b").animate({left: "-=300"}, 2000,moveRight)
}
$(document).ready(function() {
moveRight();
});
</script>
see pic:
now!
go to Layout and add a gadget and input your HTML code into that!
<img id="b" src="http://www.web-press.it/folder/servizi_cloud.jpg" id="b" style="position:absolute; top:50px"/>
see pic:
Notice:
you must add Jquery libararies before your Jquery codes
if you want to show this effects only in posts, go to
blogger.com -> New Posts
and in edditor box, click on HTML and past your HTML Codes into that
Related
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 4 years ago.
Improve this question
<script>
function addMoreAns() {
$(".add").append("<h1>Hi</h1>")
}
</script>
It is my jquery tag in javascript function.
jquery tag don't work under javascript function
You must have three things for your code to work:
You must make sure to have the JQuery library referenced prior to your use of any JQuery code.
In the HTML, you must have an element that is allowed to contain content with an add class.
You must invoke your function somehow. Just writing a function isn't the same thing as running it. You have to decide when the function should run and set up your code to invoke it at that point.
In the example below, the function is invoked every time the button is clicked.
document.querySelector("input[type=button]").addEventListener("click", addMoreAns);
function addMoreAns() {
$(".add").append("<h1>Hi</h1>")
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" value="Click to Add">
<div class="add"></div>
You need to load the jQuery library in the head of your page
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
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 5 years ago.
Improve this question
I am using a simple jQuery code that should log something to the console, but it doesn't do anything. This is my code:
<a class="header_contact" id="trigger_kontakt">Kontakt</a>
<a class="header_search"><img id="trigger_suche" src="someimage.jpg" /></a>
$("#trigger_kontakt").click(function() {
console.log("Kontakt");
(".contact_box").addClass("active");
(".search_box").removeClass("active");
});
The JS code is loaded correctly and it is loaded AFTER the reference of jQuery; but I don't get anything logged to the console - why is that?
Thanks!
your code can't run,the $ is missing.
$("#trigger_kontakt").click(function() {
console.log("Kontakt");
$(".contact_box").addClass("active");
$(".search_box").removeClass("active");
});
.active{
color:red;
}
div{ width:100px;height:50px;border:1px solid #000;display:inline-block;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a class="header_contact" id="trigger_kontakt">Kontakt</a>
<a class="header_search">Search</a>
<br>
<div class='contact_box'>.contact_box</div>
<div class='search_box'>.search_box</div>
Maybe you should try listening of the document is ready by putting your code in like this
$( document ).ready(function() {
console.log( "ready!" );
});
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am working on a mobile application, I am trying to make an image as a button: I have an image and I want to click on it, then when I click the mobile gallery opens so that I can upload a photo.
Any help please?
I think, you want to open file-uploader on image button click! Right?
If so, you can use pure javascript / jQuery as following:
HTML:
<div id="profilepic">
<input id="fileSelector" type="file" name="file" accept="image/*" capture="camera" />
<button id="clickButton" onClick="openFileUpload();"><img src="Images/profilepic.png" width="170" height="170"/></button>
</div>
For jQuery append this to head of your document:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
Wrap following code in head too.
JQuery:
$(document).ready(function(){
$('#clickButton').on('click', function(){
$('#fileSelector').click();
});
});
OR Javascript:
function openFileUpload(){
document.getElementById('fileSelector').click();
}
http://jsfiddle.net/mas5qr1o/1/
See demo here:
jQuery DEMO
Javascript DEMO
Try the following jquery
$('#clickButton').on('click', function(){
$('#fileSelector').trigger('click');
});
DEMO
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
jQuery:
$(document).ready(function(){
$("button").click(function(){
$("#message").show();
});
});
HTML:
<div id="message">
<p> You will be their life line, please take your purchase seriously.</p>
</div>
This is the code that I have but I want to either show a message on click or animate it but I don't want it visible until clicked.
USe css for that
#message
{
display:none;
}
Or you can use jquery too.
$(document).ready(function(){
$("#message").hide();
$("button").click(function(){
$("#message").show();
});
});
Firstly, you need to set display in css:
#message{
display: none;
}
And then call the jquery to show it when the button is clicked:
$(document).ready(function(){
$("button").click(function(){
$("#message").show();
});
});
Using CSS:
<div id="message" style="display:none;">
Using JS:
$('#message').hide();
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have got this certain script from a site. I put it on a div. I want to do something like this. http://www.upesspe.org/ But I can't tackle with the script in any way.
http://oil-price.net/dashboard.php?lang=en
Javascript
< script > $(document).ready(function () {
$('#first').click(function () {
$('#wti').slideDown(500);
});
$('.script').mouseLeave(function() {
$('#wti').slideUp(500);
});
}); < /script>
HTML
<div class="script">
<div id="first" class="header_06">WTI Crude Oil</div>
<div id="wti">
<script type="text/javascript" src="http://www.oil-price.net/TABLE2/gen.php?lang=en">
</script>
<noscript>To get the WTI oil price, please enable Javascript.</noscript>
</div>
</div>
DEMO: http://jsfiddle.net/rockyddev/9csnk/5/
PS - I updated
mouseLeave should be in lower case and remove the <script> tags in jQuery. Try with the following code:
$(document).ready(function () {
$('#first').click(function(){
$('#wti').slideDown();
});
$('.script').mouseleave(function() {
$('#wti').slideUp(500);
});
});