onClick display none

How do I use javascript or jQuery to display:none on a background image, onClick only.

Thank you

If the element that has the background image has an id of ‘theElem’ then the JavaScript to make the background image disappear when that element is clicked would be

document.getElementById('theElem').onclick = function() {document.getElementById('theElem').style.backgroundImage = 'none';};

If the element is identified some other way them you’d use that in place of the id.

If you want the entire element to be removed from the page you’d substitute display for backgroundImage

hello felgall, that worked great, however, I didn’t take into consideration tabbing through the fields would not work. It only works onclick, is there another command that would work with both tabbing and clicking in a field?

Thank you

The keyboard equivalent to clicking the mouse button is to tab to the field and then press the enter key. Just tabbing to the field triggers an onfocus event.

Thank you, that worked better. It worked for onclick and onfocus.