Chikwado Posted August 14, 2015 Share Posted August 14, 2015 Some one check this: Javascript second call function, for example: when i click first button to triger a function it displayed, then in that dispayed field another trigerable button are there, I want to call it and dispaly in a div. Link to comment Share on other sites More sharing options...
davej Posted August 14, 2015 Share Posted August 14, 2015 All sorts of problems in these lines... <scrpt type="text/javascript" src="jquery-1.11.2.min.js"></script><script type="text/javascript" src="myjavascript.js"></script></head><body><header claas="levela"> Link to comment Share on other sites More sharing options...
thescientist Posted August 14, 2015 Share Posted August 14, 2015 what's the question? is something broken or are you asking us how to do it? Link to comment Share on other sites More sharing options...
Chikwado Posted August 15, 2015 Author Share Posted August 15, 2015 (edited) This is what am doing here http://chiquado.site90.net/tutorial.html. When you click those navigation bar, It display a page with hyper link. If click those new link it does not goes anywhere. The first navbar is a function and second is a function. The first one work fine but the second one does not. Edited August 15, 2015 by Chikwado Link to comment Share on other sites More sharing options...
dsonesuk Posted August 15, 2015 Share Posted August 15, 2015 I don't know if you have fixed this, but it does work in Firefox anyway, you might not be able to tell because the last few links, text is the same. Link to comment Share on other sites More sharing options...
Chikwado Posted August 15, 2015 Author Share Posted August 15, 2015 (edited) Let me explain to you what I want to do: 1 create a navbar. 2 when you click the navbar it will call a page and dispaly them in aside. 3 page in aside is also a hyper link, if you click the link in aside it call a new page in the section. All these are javacript function. Edited August 15, 2015 by Chikwado Link to comment Share on other sites More sharing options...
dsonesuk Posted August 16, 2015 Share Posted August 16, 2015 Elements must exist when binding a event handler, you are creating elements with event handlers that do not exist on page load, with such elements you have to identify the element and bind a onclick event to reference the function after creating each elementSimilar to document.getElementById('created_element_identifier').onclick=function(){Runthis_specific_function()}A better option would be have all grouping of links in their own containers and hide on load, then unhide them when required, they would then exist page onload and there respective call to a function would be handled by its bound event. Link to comment Share on other sites More sharing options...
Chikwado Posted August 23, 2015 Author Share Posted August 23, 2015 (edited) Can some one help view this code once more. document.getElementById("demo").onclick=function() { var stuff = "Hello second call!"; document.getElementById("div2").innerHTML = stuff; } } When I hit the new link It does not call anything. Edited August 23, 2015 by Chikwado Link to comment Share on other sites More sharing options...
davej Posted August 23, 2015 Share Posted August 23, 2015 Are you trying to create a closure? You have a function inside a function. --edit-- OK, now you have edited it and it should work as long as you call it after the page has loaded. You can do this... window.onload = init;function init(){ document.getElementById("demo").onclick = handler1;}function handler1(){ var stuff = "Hello second call!"; document.getElementById("div2").innerHTML = stuff;} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now