How to make a closable banner in pure javascript [closed] - javascript

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 want to make a closeable banner like this one at the top:
http://i.stack.imgur.com/t2m9U.jpg
using only html, css, and javascript

Check this bootstrap example: http://www.bootply.com/91822
Or this fiddle I just quickly put together: http://jsfiddle.net/foxu9o9d/
the JS goes along the lines of:
var btn = document.querySelector('#btn-dismiss');
btn.addEventListener("click", function(){
var alert = document.querySelector('#fixed-alert');
alert.style.display = 'none';
});

Related

How to change cursor to custom after clicking on button [closed]

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 2 years ago.
Improve this question
I would like to change my cursor after clicking on button (on whole page), and save it somewhere maybe in localstorage, beacause after refreshing or changing the page i still want to have this custom cursor.
I want to apply custom cursor with URL.
you can read about limitations and rules about cursor here
<button onClick="changeCursor()">Click Me!</button>
<script>
function changeCursor() {
document.getElementsByTagName('body')[0].style.cursor = "url('my-cursor.png'), auto";
localStorage.setItem('customCursor', 'true');
}
window.onload = function() {
if(localStorage.getItem('customCursor') == 'true') {
document.getElementsByTagName('body')[0].style.cursor = "url('my-cursor.png'), auto";
}
}
</script>

Hide and show again div [closed]

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 2 years ago.
Improve this question
How do I need to change my code if I click .menu again, I want to show .work?
$(".menu").click(function () {
$(".work").css("display", "none");
});
Use JQuery's .toggle method:
https://api.jquery.com/toggle/
$(".menu").click(function () {
$(".work").toggle();
});

How do I apply a style based on a condition (return value from a function in JS)? [closed]

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 7 years ago.
Improve this question
I am using simple html and associated JS code. I have a statement like this in my html code:
<td class="ui-navigation-static-menu-holder" style="width: 147px; display: block">
I want to apply the display: block style only when a particular condition is true (say isStyleBlock() in my associated JS code).
How can I achieve that?
if(isStyleBlock()) {
elem.style.display = 'block'
}

on value set function in jquery or javaScript? [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 8 years ago.
Improve this question
I create a sample when you type in input element run a function
But I need when it change by another function , run a function !
see it and help me : http://jsfiddle.net/pxfunc/5kpeJ/
$('#modern').bind('input', function() {
$(this).next().stop(true, true).fadeIn(0).html( $(this).val()).fadeOut(2000);
});
when click on button function not Run !
like this http://jsfiddle.net/5kpeJ/902/ ?
you should create a trigger and run it
$("input").focus(function(){
$("<span>Focused!</span>").appendTo("body").fadeOut(1000);
});

Using Javascript, can I dynamically create a button and then remove it as needed? [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 8 years ago.
Improve this question
Using Javascript and HTML, I am trying to have a series of buttons that when clicked on:
1) Dynamically create 3 sub buttons with different options
2) Once an option is selected, I want to remove the 3 new buttons and save their election out to a variable.
Essentially, I am trying to replicate what I am seeing done at http://interactiverenderings.com/.
Here is a JsFiddle
to get you started.
<div id="test"></div>
<script>
var dynamicBtn=document.createElement("BUTTON");
var buttonText=document.createTextNode("Hello...");
dynamicBtn.appendChild(buttonText);
document.body.appendChild(dynamicBtn);
dynamicBtn.onclick = function(){alert("Hi")};
</script>
You can do it the following way
var myDiv = document.getElementById("YOUR_DIV");
var btn = document.createElement("input");
btn.type = "button";
myDiv.appendChild(btn);

Categories