Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to access content of p tag

 
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to access content of tag with id hours and mins. But it is not working. Please let me know, how to access content of p tag
I have tried following also, but I am not getting value from javascript.
I have tried following code, but gethrs() does not trigger with onload event. why

Thanks
 
Bartender
Posts: 2265
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only input elements have values and .text does not exist.

Eric
 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I am using this code, still its not working. WHen I add "document.getElementById("hours").innerHTML = dtObj.getHours();" , code stops working. If this line is not added in javascript, all alerts upto 4 are working. So there is something wrong with this code, which stops everything. What can be wrong with this ?


Whats the difference between two codes ? Bottom one is working, top one is not. I wouldlike to know the bug, this thing keeps happening.

Thanks
 
Marshal
Posts: 25835
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Surely there must be something in the Javascript console if your Javascript code ends unexpectedly?
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not always. De-referencing an undefined values often results in a silent failure. It's sometimes infuriating.

So, what has been done to verify that the items that are being dereferenced are not undefined?
 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have re-written the code in a new file and its working.

Now this is my question. Where shall I start from for such a bug ? Now in this case, as you mentioned " what has been done to verify that the items that are being dereferenced are not undefined? " How can I verify this ?

Thanks
 
Do not threaten THIS beaver! Not even with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic