Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Javascript replace div content onclick a button

<div id = "div1" style="display:block"><img src="1.jpg" /></div>

<div id = "div2" style="display:none"><img src="2.jpg" /></div>

<button type="submit" onclick = "replace()">change content</button>


<script type = "text/javascript">
function replace() {
document.getElementById("div1").style.display="none";
document.getElementById("div2").style.display="block";
}

</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to send enter event to input field jquery 
Javascript :: A <Route is only ever to be used as the child of <Routes element, never rendered directly. Please wrap your <Route in a <Routes. 
Javascript :: react-native razorpay 
Javascript :: get version from package.json 
Javascript :: remove id attribute javascript 
Javascript :: setinterval js 
Javascript :: two sum javascript solution 
Javascript :: unique element in array 
Javascript :: jquery form data 
Javascript :: debounce js 
Javascript :: find last element in array nodejs 
Javascript :: javascript how to sort alphabetically 
Javascript :: tolocaledatestring format dd-mm-yyyy 
Javascript :: wordpress javascript localization 
Javascript :: js get element by index 
Javascript :: formik react native 
Javascript :: on() jquery 
Javascript :: find a single element in array of objects javascript 
Javascript :: laravel link custom javascript file 
Javascript :: react-native safeareaview 
Javascript :: Javascript removing duplicates in array 
Javascript :: Disable click for specific elements javascript 
Javascript :: js list pf objects 
Javascript :: js how to work with float 2 decimal numbers 
Javascript :: convert an array to string javascript 
Javascript :: import bootstrap in react 
Javascript :: toastr alert js 
Javascript :: javascript random text from array 
Javascript :: react router get data from url 
Javascript :: reset form jquery | form reset javascript/jquery 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =