i want to heading in above and icon list content with this each image...its hide and show images with text..
when click each button.button1 shows button1 images with heading and when i click button2 button1 is hide and show button2 images with content in same palce.this is the codinInitial Image Show/Hide CSS
Button Data Attribute
data-showme|IMAGE-ID-NAME
Dynamic Image Hide/Show JS
i want to heading in above and icon list content with this each image...its hide and show images with text..
when click each button.button1 shows button1 images with heading and when i click button2 button1 is hide and show button2 images with content in same palce.this is the codinf
You can use something like Display: none when the button is click see below example for reference.
HTML Code:
<div id="button-01" style="display: none"> <button onclick="closebutton1()">button-1</button> </div> <div id="button-02" style="display: none"> <button onclick="closebutton2()">button-1</button> </div>
JS Code:
function closebutton1(){ document.getElementById('button-02').style.display = 'none'; document.getElementById('button-01').style.display = 'block'; } function closebutton2(){ document.getElementById('button-02').style.display = ''; document.getElementById('button-01').style.display = 'none'; }
Related
Im trying to do; show divs when click on check-box radio button. I made it with jquery but when you load page all my divs are visible. You have to click my first check-box radio button to make other divs invisible. or just click other check-box radio buttons.
I tried
#row2 {
display:none;
}
But when I added this to css, if you click first check-box radio button(which is related to div row2) div is not visible and and it is not working.
Any other solution for when you open page I just want to see only div (row2) which is checked. I dont want to see other divs when page load.
Thanks...
Demo Link: https://rexin-demo.netlify.app/main.html
Ps: Pics and button are not visible on jsfiddled cuz of assets. Better to look it via demo link.
https://jsfiddle.net/t4e13xvj/
Trigger the click by adding .filter(':checked').click() at the end of the input's click event .. Try it
$(document).ready(function(){
$('input[type="radio"]').click(function(){
var inputValue = $(this).val(); // use .val() instead of .attr('value')
var targetBox = $("." + inputValue);
$(".box").not(targetBox).hide();
$(targetBox).show();
}).filter(':checked').click();
});
Also I prefer to use change instead of click for radio and checkbox inputs
$(document).ready(function(){
$('input[type="radio"]').on('change' ,function(){
if(this.checked){
var inputValue = $(this).val();
var targetBox = $("." + inputValue);
$(".box").not(targetBox).hide();
$(targetBox).show();
}
}).filter(':checked').prop('checked' , true).change();
});
OR With only css you can use
.box:not(.product){
display : none;
}
I have an image button in a div when click I want to hide image button and somehow store to local storage not to show div again on page refresh.
<div class="whatsapp"><a href="https://chat.whatsapp.com/........." target="_blank">
<img src="/img/whatsapp_group.png" alt="Whatsapp Join Button"><div class="whatsappbut">To Find Out MORE!</div></a></div>
I added an ID(id="img-btn") to your div to use it in script tag. If user didn't click on your image button so far, localStorage.getItem('img-btn-clicked') will return null otherwise it'll return 'true'(as we set it in saveClicked function).
Just make sure to put the script tag before the body tag ends(or you can link a separated Javascript file).
<body>
<div id="img-btn" class="whatsapp">
<a href="https://chat.whatsapp.com/........." target="_blank">
<img src="/img/whatsapp_group.png" alt="Whatsapp Join Button" />
<div class="whatsappbut">To Find Out MORE!</div></a>
</div>
<script>
checkImgBtnClicked();
function checkImgBtnClicked() {
const clicked = localStorage.getItem('img-btn-clicked'); // if this is not set it will return null
if (clicked) {
document.getElementById('img-btn').style.display = 'none'; // hides the img-btn
} else {
// add event listener for image button click(saveClicked function will be executed if user clicks on image button
document.getElementById('img-btn').addEventListener('click', saveClicked);
}
}
function saveClicked() {
// set a flag in local storage that image button is clicked
localStorage.setItem('img-btn-clicked', 'true');
document.getElementById('img-btn').style.display = 'none'; // hides the img-btn after it gets clicked
}
</script>
</body>
I am using NgbModal model for modal popup(dialog) in angular 6.
I have a parent form with button, when clicked onto that button it opens the popup.
so my requirement is, when modal pops up, the background (parent form) should be editable or clickable.
also when ever modal pops up the background should be in Editable mode.
i have tried data-keyboard="false" data-backdrop="static" properties to make the parent form editable.
but this doesn't work.
<button aria-label="matMenuButton" mat-icon-button (click)="open()">
<mat-icon aria-label="menu" aria-hidden="false">picture_in_picture</mat-icon>
</button>
<div>
<div class="modal-header">
</div>
<div class="modal-body">
</div>
<div>
component that opens :
open() {
this.modalRef = this.service.openTest('Test View');
}
openTest(title: string) {
this.modalRef = this.service.open(TestComponent, { size: 'sm' });
}
When ever the modal (dialog) pops up,
the background (parent form) should be editable always.
I have ng-repeat on a div that contains a button. Say the div repeats 5 times with 5 buttons. I want to disable the 2nd button when it is clicked. How can I disable the button at that index?
<div ng-repeat='thing in things'>
<button ng-click='clickToDisable($index)'>button</button>
</div>
Something like this. I tried ng-disabled= 'disableButton == $index but that just disables all of the buttons.
You can pass in the $event into the click function and set the disabled attribute to true, like this:
<div ng-repeat='thing in things'>
<button ng-click='clickToDisable($event)'>button</button>
</div>
And in the controller:
$scope.clickToDisable = function(evt) {
evt.currentTarget.setAttribute('disabled', 'true');
}
Here is a fiddle of it working.
i have the following code :
<html>
<head><title></title>
<script>
function showMe (it, box) {
var vis = (box.checked) ? "none" : "block";
document.getElementById(it).style.display = vis;
}
</script>
</head>
<body>
<input type="checkbox" name="c1" onclick="showMe('div1', this)">Show Hide Checkbox
<div id="div1">
<h3 align="center"> test </h3>
</div>
<form>
</form>
</body>
I want to toggle the div, the code above works however when the script loads the div is visible. How can i set the div to hidden when the script loads? (i know that if i set the div outside the tags it works however i want to toggle them inside).
Set the div tag to display:none initially. And flip the condition of the if.
Like:
function showMe (it, box) {
var vis = (box.checked) ? "block":"none";
document.getElementById(it).style.display = vis;
}
<div id="div1" style="display:none">
I do something very similar on one of my pages and I include this in the div
style="display:none"
That seems to work for me, and then it gets changed to block when i click my show/hide button