I have to toggle the name of a hyperlink from Edit to Save and vice-versa on click event of the same hyperlink.
This is the HTML part,
[HTML]<input class="text" id="ix1" type=text></input>
<a class="button" id="ax1" href="javascrip t:void(0)" onclick="edit(' x1')"> Edi t </a>[/HTML]
and function edit(id) is
The code in bottom line is working fine with all browsers, ie. class name of the input box gets changed on hyperlink's click.
But the name-change of the hyperlink is working fine with Firefox and IE only, ie, the name of the hyperlink gets changed from ' Save ' to ' Edit ' and ' Edit ' to ' Save ' on every click. But Opera and Safari are not doing any change.
If I remove the , then its working fine with all.
But since its a button kind of look, so I need to give space on both sides of the name.
I know I can solve it with this change...
but what's the problem with reading ?
This is the HTML part,
[HTML]<input class="text" id="ix1" type=text></input>
<a class="button" id="ax1" href="javascrip t:void(0)" onclick="edit(' x1')"> Edi t </a>[/HTML]
and function edit(id) is
Code:
function edit(id) {
var anc = document.getElementById('a'+id);
var inp = document.getElementById('i'+id);
anc.innerHTML = anc.innerHTML==" Edit " ? " Save " : " Edit ";
inp.className = inp.className=="text" ? "edit" : "text";
}
But the name-change of the hyperlink is working fine with Firefox and IE only, ie, the name of the hyperlink gets changed from ' Save ' to ' Edit ' and ' Edit ' to ' Save ' on every click. But Opera and Safari are not doing any change.
If I remove the , then its working fine with all.
But since its a button kind of look, so I need to give space on both sides of the name.
I know I can solve it with this change...
Code:
anc.innerHTML = inp.className=="text" ? " Save " : " Edit ";
Comment