09-30-2008, 10:56 AM
|
#3 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
|
Yes that would work, although there is one thing: the 'onclick' is a property that accepts a reference to a callback, therefore using it as a function will ultimatly end in an error:
Code:
this : element.onclick(function(){
produces this error:
getElementsByName("underline")[0].onclick is not a function
The correct code would be:
javascript Code:
var element=document.getElementsByName('underline')[0];
element.onclick = function(){ document.getElementsByName('comment')[0].innerHTML+='<u> </i>'; };
This code can be made shorter:
javascript Code:
document.getElementsByName('underline')[0].onclick=function(){ document.getElementsByName('comment')[0].innerHTML += "<u></u>" };
Or you could use jQuery:
javascript Code:
$('input#underline').click(function(){$('textarea#comment').text("<u></ul>")});
if you give the elements id's
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
Last edited by sketchMedia : 10-02-2008 at 06:58 PM.
Reason: missed the '+' on the second example
|
|
|
|