Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
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.
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
Improve this question
I would like to know if it's possible to convert the following css to javascript? so basically it should implement the style rules after the onchange.
.appnitro input:required:valid, .appnitro textarea:required:valid {/* when a field is considered valid by the browser */
box-shadow: 0 0 5px #5cd053;
border-color: #28921f;
}
.appnitro input:focus:invalid, .appnitro textarea:focus:invalid { /* when a field is considere invalid by the browser */
box-shadow: 0 0 5px #5d45252;
border-color: #b03535;
}
<script>
function myFunction(){
??????
}
</script>
<form id="form_664184" class="appnitro" method="post" action="">
<input type="text" id="element_3" name="element_2_1" value="Title" onchange="myFunction()" required />
</form>
Yes, it is. Here is how it should be:
yourElement.style.borderColor = "#5cd053";
yourElement.style.boxShadow = "#5cd053";
Get the element by ID, class name or whatever else.
Related
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 6 years ago.
Improve this question
I am trying to display the data of a div tag on a href click, the id is dynamically made. But the div tag is not responding. The sequence of the code is as below. The file is the .tpl file.
function editPickUpAddress(divId)
{
("#pickupAddressForm_"+divId).show();
}
<a href style="float:right;margin-top:-20px;margin-right:100px;" onclick="editPickUpAddress({$item.profile_id});">Edit</a>
<div id="pickupAddressForm_{$item.profile_id}" style="display:none">
//some content to display
</div>
After cleaning up your snippet and including jQuery, the code works as intended. Also note the href="#" which prevents the anchor tag from navigating to another page.
function editPickUpAddress(divId) {
$("#pickupAddressForm_" + divId).show();
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Edit
<div id="pickupAddressForm_1" style="display:none">
//some content to display
</div>
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 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've tried working with this but I think it is a problem with the jquery, my cloud9 thing says that '$ is not defined'
Here is my code: https://jsfiddle.net/qLuvsy9y/6/
Another example: http://jsfiddle.net/5udtC/6913/
<div class="wanted"> <!-- Toggle Lowercase -->
<label class="input-toggle">
<input type="checkbox" id="isAgeSelected" checked>
<span></span>
</label>
</div>
<p> Upper Lower Case Mix</p>
<div class="hide">
<div id="txtAge" style="display:none">
<div class="wanted"> <!-- Toggle Uppercase -->
<label class="input-toggle">
<input type="checkbox" id="uppercase" checked>
<span id="randomString"></span>
</label>
<p id="test1">Uppercase</p>
</div>
Jquery
$('#isAgeSelected').change(function() {
$("#hide").toggle(this.checked);
});
if you cloud9 "thing" is saying $ is not defined then you are either not including the jquery library in your document or not wrapping your code in a document ready statement and the browser is trying to execute code too early.
you need to include the jquery library: either from a local file - such as:
<script src="js/jquery-2.1.1.js"></script>
or from a CDN - such as:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
and then you need to wrap the jquery in a document ready statement to ensure that the library has loaded before tying to execute jquery commands:
$(document).ready(function(){
$('#isAgeSelected').change(function() {
$("#hide").toggle(this.checked);
});
});
and then you have a div with a class of "hide", but you are attempting to modify an element with an ID of "hide" in your code. These need to be the same:
$("#hide").toggle(this.checked);
should be
$(".hide").toggle(this.checked);
or change the div to be:
<div id="hide">
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 a list of items in my app that have radio buttons on them. As I change the settings on the radio buttons, I want to update the running total at the bottom of the page. How do I set up the running totals?
This has some flaws to it, but it should get you started:
<html>
<head>
<script>
var total = 0;
function count(input) {
if(input.checked) {
total++;
}
document.getElementById('total').innerHTML = total;
}
</script>
</head>
<body>
<input type="radio" id="radio1" onclick="count(this);"/>Radio 1
<span id="total">0</span>
</body>
</html>
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);
});
});