Reputation: 161
I have a button on my website but when I click, it doesn't respond. But the other button works. The location of the button where i got the error(which it doesn't respond to my click) is a bootstrap dialog. But the other bootstrap dialog works fine. May I have any suggestions or solutions ?
Following is the html code
<button type="button" class="btncanceldocument btn btn-warning" >
Cancel Document
</button>
And this is the javascript code
$(document).ready(function () {
$('.btncanceldocument').click(function () {
alert("Say hello");
});
});
Is there something wrong with it? if not i think the problem is on other javascript code. So how can i find the problem using my browser? or does my browser print some error? I have lots of javascript code on this file. I can't find the problem or error?
Upvotes: 0
Views: 88
Reputation: 459
To answer your question, most browsers have a built in debugging tool. My personal favourite is Chrome.
If you right-click anywhere on your page then choose 'inspect' you will open it.
Here is a link that will help you - https://developers.google.com/web/tools/chrome-devtools/?hl=en
It's worth spending some time learning about that as it will save you in the long run.
When you open the debug you will be able to run JS code in the console, so you can manually fire your click using:
$('.btncanceldocument').click();
Then you will be able to make sure your code is working. If clicking with your mouse isn't working sometimes it could be as the button is actually behind a transparent element.
In the debug tool you are also able to select HTML elements so you can see if something is blocking the button. A quick tip for checking this is if you increase the CSS z-index property on the button to a large value e.g. '9999999999999' . This will bring the button 'above' the other content of the page.
Hopefully this helps,
Pete
Upvotes: 1