• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to access content of p tag

 
nirjari patel
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
 
Swastik Dey
Rancher
Posts: 1602
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this
 
Eric Pascarello
author
Rancher
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
 
Paul Clapham
Sheriff
Pie
Posts: 20729
30
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic