• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Change in the text

 
Romeo Ranjan
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

Below is the code I am using


The code actually hides the content of the table when the image is clicked. and displays the content when the image is again clicked. What I want is the change in the text next to that, it should say Hide Table when the content of the table is displayed and Show Table when the content of the table is hidden. How do I go about doing this? need some ideas.
Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isolate the text to be manipulated in a <span> and then use innerHTML to change its contents.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S <b> is outdated. Use CSS.
 
Romeo Ranjan
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Isolate the text to be manipulated in a <span> and then use innerHTML to change its contents.


Can you please elaborate on the part on how to use innerHTML to change the contents?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get a reference to the element and set its innerHTML property to whatever you want.
 
Romeo Ranjan
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Bear,

As you have suggested I have isolated the text in the span tag





I am still not able to understand when you said get reference to element and change its innerHTML, when you said reference to element which one did you mean? should i write javascript..I am kind of totally confused, please give me some examples..
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you are trying to do with the hide and show classes.

Give the span element an id so you can reference it. Such as:

Then, to change its content:

To show:
To hide:
 
Romeo Ranjan
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Bear,

Thanks a lot for explaining it step by step. It helped me solve the problem.

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic