meemee
01-09-2012, 07:20 AM
I am having problem with editing string on mouse click.
I have a string of text like this:
id1=&id2=&id3=&id4=&
And now I need to show/hide part of string by clicking on a links. I would like to hide/show each id's (i.e. id1=&)
It is simple to hide whole text but how about part of it ?
devnull69
01-09-2012, 07:49 AM
You would need to wrap the parts (let's say in <span>) before you can hide them
Something like
<span id="id1">id1=&</span><span id="id2">id2=&</span><span id="id3">id3=&</span><span id="id4">id4=&</span>
Then you can use code like
document.getElementById('id2').style.display = 'none';
to hide a certain part
meemee
01-09-2012, 08:07 AM
Is it possible to assign each id as var? i.e.
var id1 = id1=&
var id2 = id2=&
var id3 = id3=&
var id4 = id4=&
And then somehow show/hide each var ?
Philip M
01-09-2012, 08:25 AM
Is it possible to assign each id as var? i.e.
var id1 = id1=&
var id2 = id2=&
var id3 = id3=&
var id4 = id4=&
And then somehow show/hide each var ?
No, that is not possible. Do what devnull69 has suggested.
meemee
01-09-2012, 08:32 AM
The problem is that I need to use string combined of all those id's in a link parameter so the whole link will look like:
src='/images/engine_components/obd.svg?id1=&id2=&id3=&'
so it is not ideal to have <span> tags inside :)
devnull69
01-09-2012, 01:50 PM
You can still get the text only content using .innerText() ... it will automatically crop the span elements