Search code examples
javascripthtmlinputbold

Javascript HTML string


I have an input box with an I.D. of "q" on my website...

By entering javascript into the URL bar I can change the place holder text (client side) to say "test"

javascript:void(document.getElementById('q').value='test');

Now if I wanted to make it say test (but in bold with html) how would I do that?? I tried:

javascript:void(document.getElementById('q').value='<b>test');

But that won't work.. it's a string! I don't know much javascript...

Thanks all!


Solution

  • try:

    document.getElementById('q').style.fontWeight = 'bold';
    

    EDIT:

    it should work fine:

    <a href="javascript:void(document.getElementById('q').style.fontWeight='bold');">bold</a>
    <input type="text" id="q" value="some text" />