Click here to Skip to main content
14,930,311 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
below is the simple code for html button and javascript if i click the button, corresponding javascript function is not working. is anything wrong in below code? and I used bootstrap button.

HTML
<button type="button" class="btn btn-primary btn-sm" onclick="myFunction()" id="reqst">Send Request</button>

JavaScript
<script>
function myFunction{
document.getElementById("reqst").innerHTML="hello world";

}
</script>
Posted
Updated 1-Nov-20 6:08am

If course it does work, but your function is lexically incorrect (so even exception handling would not help). It should be
JavaScript
function myFunction() {
   //...
}
If you add this '()', it should work.

—SA
   
Put () in ur function.check the solution 1.
JavaScript
<script>
function myFunction() {
document.getElementById("reqst").innerHTML="hello world";

}
</script>
   
var parr = document.getElementById('hy'),
but = document.getElementById('butt'),
diiv = document.getElementById('dvd');

function myFunction(){
"use strict";
if(parr.classList.contains(but.textContent)){ //if(parr.classList.contains(but.textContent)){
diiv.innerHTML = "yes";console.log('hi')
}
};
dont working
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900