Dogberry Posted May 23, 2014 Share Posted May 23, 2014 var today_obj = new Date();var today_date = today_obj.getDate();var tips;tips = []; Thereafter I have 31 tips one for each day of the month. The script ends with document.write(tips[today_date]); Both JSLint and JSHint are giving me grief over the document write statement. Can anyone give me an alternative that will keep these two beasts happy and still give me what I want. Many thanks for your time and efforts in advance. Chris Link to comment Share on other sites More sharing options...
Ingolme Posted May 23, 2014 Share Posted May 23, 2014 Modify the innerHTML of an element or create and append new DOM nodes to the document. Link to comment Share on other sites More sharing options...
MrFish Posted May 24, 2014 Share Posted May 24, 2014 Modify the innerHTML of an element or create and append new DOM nodes to the document. This. I assume you're new to js so to do that I'd recommend going inserting new DOM nodes (cleaner imo). var myText = document.createElement("span");myText.innerHTML = "This is a note";document.getElementById("my_container").appendChild(myText); But I'd really recommend AngularJS if you're updating html. It has 2-way binding which means whenever you update a variable the view (your html) will update automatically. And whenever you update an input the controller will update. Save a lot of time and frustration. Link to comment Share on other sites More sharing options...
Dogberry Posted May 25, 2014 Author Share Posted May 25, 2014 Thanks for the replies and yes I am very new to this. I do not fully understand the replies but at least you have given me some more research to do in the right paths much obliged. Chris Link to comment Share on other sites More sharing options...
thescientist Posted May 27, 2014 Share Posted May 27, 2014 But I'd really recommend AngularJS if you're updating html. It has 2-way binding which means whenever you update a variable the view (your html) will update automatically. And whenever you update an input the controller will update. Save a lot of time and frustration. that's seems like a steep learning curve to take on for someone very new to Javascript. AngularJS is good, but definitely not something to take on the beginning of one's period of development. Link to comment Share on other sites More sharing options...
Ingolme Posted May 27, 2014 Share Posted May 27, 2014 I wouldn't recommend frameworks to anybody who doesn't have good experiente with plain Javascript. 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