Hi,
I try to use this Js and Html : jsfiddle, but in my website (top left) it dont work!!!
is there any conflict with others JS code, or what?
Thanks
Hi,
I try to use this Js and Html : jsfiddle, but in my website (top left) it dont work!!!
is there any conflict with others JS code, or what?
Thanks
You have errors in your JavaScript.
To see them, open your page > hit F12 (brings up the browser tools) > hit console.
(index):1 Uncaught TypeError: Cannot set property 'innerHTML' of null
(index):2 Uncaught TypeError: undefined is not a function
Inspecting the source shows the culprit to be:
document.getElementById('Time').innerHTML
You do have an element with an id of Time
on the page, but you are trying to reference it before it exists.
To solve this problem, move the JS to the foot of the page. You can place it in the jQuery(document).ready(...)
block you already have:
jQuery(document).ready(function($) {
$(".accordion_top").smk_Accordion({closeAble: true,showIcon: false,});
$(".accordion_footer").smk_Accordion({closeAble: true});
document.getElementById('Time').innerHTML = today.getHours();
if (today.getHours() < 0 || today.getHours() >= 18) {
document.getElementById('Bonjour').innerHTML = 'Test Bonsoir';
}
});
Actually, while youâre at it, you might as well take use of jQueryâs more concise syntax:
jQuery(document).ready(function($) {
$(".accordion_top").smk_Accordion({closeAble: true,showIcon: false,});
$(".accordion_footer").smk_Accordion({closeAble: true});
$('#Time').html(today.getHours());
if (today.getHours() < 0 || today.getHours() >= 18) {
$('#Bonjour').html('Test Bonsoir');
}
});
Thanks a lot for your help.
Merci.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.